summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-11-17 11:59:24 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-11-17 11:59:24 +0000
commit3cc2e824092b0b542b3d1857bb742514560b0f32 (patch)
treee0140f4b137c13a1e47487a1e6aa50f1d492d157 /protocols
parent2dcdda76b6e9434ae5b05699d218b0ac17651d50 (diff)
Skype:
better way of finding running process git-svn-id: http://svn.miranda-ng.org/main/trunk@2335 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Skype/src/skype.cpp25
-rw-r--r--protocols/Skype/src/skype.h1
2 files changed, 19 insertions, 7 deletions
diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp
index ec2ab96e92..77fbac14b5 100644
--- a/protocols/Skype/src/skype.cpp
+++ b/protocols/Skype/src/skype.cpp
@@ -250,7 +250,7 @@ int StartSkypeRuntime()
PROCESS_INFORMATION pi;
TCHAR param[128];
- ZeroMemory(&cif,sizeof(STARTUPINFO));
+ ZeroMemory(&cif, sizeof(STARTUPINFO));
cif.cb = sizeof(STARTUPINFO);
cif.dwFlags = STARTF_USESHOWWINDOW;
cif.wShowWindow = SW_HIDE;
@@ -317,14 +317,25 @@ int StartSkypeRuntime()
}
}
- if (FindWindow(NULL, szFilename))
- port += rand() % 100;
-
+ PROCESSENTRY32 entry;
+ entry.dwSize = sizeof(PROCESSENTRY32);
+
+ HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
+ if (Process32First(snapshot, &entry) == TRUE) {
+ while (Process32Next(snapshot, &entry) == TRUE) {
+ if (_tcsicmp(entry.szExeFile, _T("SkypeKit.exe")) == 0) {
+ HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
+ port += rand() % 100;
+ CloseHandle(hProcess);
+ break;
+ }
+ }
+ }
+ CloseHandle(snapshot);
+
mir_sntprintf(param, SIZEOF(param), L"-p -p %d", port);
+ int startingrt = CreateProcess(szFilename, param, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &cif, &pi);
- int startingrt = CreateProcess(szFilename, param, NULL,
- NULL, FALSE, CREATE_NEW_CONSOLE,
- NULL, NULL, &cif, &pi);
return startingrt;
}
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h
index 398a3ad2b8..e8ffe2b3b6 100644
--- a/protocols/Skype/src/skype.h
+++ b/protocols/Skype/src/skype.h
@@ -5,6 +5,7 @@
#include <windows.h>
#include <malloc.h>
#include <shlwapi.h>
+#include <tlhelp32.h>
//#pragma warning(push)
//# pragma warning(disable:4312)