summaryrefslogtreecommitdiff
path: root/protocols/Skype
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Skype')
-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)