Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FmclientUi
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuai.liu
FmclientUi
Commits
5b7c11ed
Commit
5b7c11ed
authored
Dec 14, 2017
by
刘帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
禁止重复启动
parent
20527f5d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
3 deletions
+56
-3
.gitignore
+1
-1
FmclientUi.pro
+2
-1
app_single.h
+47
-0
bin/FmclientUi.exe
+0
-0
main.cpp
+6
-1
No files found.
.gitignore
View file @
5b7c11ed
...
@@ -68,4 +68,4 @@ Thumbs.db
...
@@ -68,4 +68,4 @@ Thumbs.db
# Binaries
# Binaries
# --------
# --------
*.exe
bin/
*.exe
FmclientUi.pro
View file @
5b7c11ed
...
@@ -24,6 +24,7 @@ SOURCES += main.cpp\
...
@@ -24,6 +24,7 @@ SOURCES += main.cpp\
HEADERS
+=
widget
.
h
\
HEADERS
+=
widget
.
h
\
fmcrypt
.
h
\
fmcrypt
.
h
\
qfmclient
.
h
qfmclient
.
h
\
app_single
.
h
FORMS
+=
widget
.
ui
FORMS
+=
widget
.
ui
app_single.h
0 → 100644
View file @
5b7c11ed
#
ifndef
APP_SINGLE
#define APP_SINGLE
#if defined WIN32 //for win
#include <windows.h>
bool
checkOnly
()
{
// 创建互斥量
HANDLE
m_hMutex
=
CreateMutex
(
NULL
,
FALSE
,
L"FmclientUi"
);
// 检查错误代码
if
(
GetLastError
()
==
ERROR_ALREADY_EXISTS
)
{
// 如果已有互斥量存在则释放句柄并复位互斥量
CloseHandle
(
m_hMutex
);
m_hMutex
=
NULL
;
// 程序退出
return
false
;
}
else
return
true
;
}
#endif
#if defined Q_OS_LINUX //for linux
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
bool
checkOnly
()
{
const
char
filename
[]
=
"/tmp/lockfile"
;
int
fd
=
open
(
filename
,
O_WRONLY
|
O_CREAT
,
0644
);
int
flock
=
lockf
(
fd
,
F_TLOCK
,
0
);
if
(
fd
==
-
1
)
{
perror
(
"open lockfile/n"
);
return
false
;
}
//给文件加锁
if
(
flock
==
-
1
)
{
perror
(
"lock file error/n"
);
return
false
;
}
//程序退出后,文件自动解锁
return
true
;
}
#endif
#endif // APP_SINGLE
bin/FmclientUi.exe
View file @
5b7c11ed
No preview for this file type
main.cpp
View file @
5b7c11ed
#include "widget.h"
#include "widget.h"
#include <QApplication>
#include <QApplication>
#include "qfmclient.h"
#include "qfmclient.h"
#include "app_single.h"
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
QApplication
a
(
argc
,
argv
);
QApplication
a
(
argc
,
argv
);
if
(
!
checkOnly
())
{
OutputDebugString
(
L"FmclientUi running."
);
return
0
;
}
Widget
w
;
Widget
w
;
QFmClient
client
;
QFmClient
client
;
QObject
::
connect
(
&
client
,
&
QFmClient
::
HideUi
,
&
w
,
&
Widget
::
hide
,
Qt
::
QueuedConnection
);
QObject
::
connect
(
&
client
,
&
QFmClient
::
HideUi
,
&
w
,
&
Widget
::
hide
,
Qt
::
QueuedConnection
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment