-
Notifications
You must be signed in to change notification settings - Fork 1
/
pytigonw.c
executable file
·54 lines (48 loc) · 1.25 KB
/
pytigonw.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <windows.h>
#include <winapi/winreg.h>
#include <stdio.h>
#include <string.h>
int key(char *bufor)
{ HKEY hKey;
int ret = 0;
LONG returnStatus;
DWORD dwType=REG_SZ;
DWORD dwSize=255;
returnStatus = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\pytigon", 0, KEY_ALL_ACCESS, &hKey);
if (returnStatus == ERROR_SUCCESS)
{ returnStatus = RegQueryValueEx(hKey, NULL, NULL, &dwType,(LPBYTE)bufor, &dwSize);
if (returnStatus == ERROR_SUCCESS) ret=1;
}
RegCloseKey(hKey);
return ret;
}
int get_program_path(char * pBuf, int len)
{
int bytes = GetModuleFileName(NULL, pBuf, len), i;
if(bytes == 0)
pBuf[0]=0;
else
if(bytes>0)
{ for(i=bytes-1; i>0; i--)
{ if(pBuf[i]=='/' || pBuf[i]=='\\')
{ pBuf[i]=0;
break;
}
}
}
}
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char bufor[256], bufor2[256];
if(key(bufor)!=1) get_program_path(bufor,256);
chdir(bufor);
strcat(bufor, "\\python\\pythonw.exe");
strcpy(bufor2, "pytigon ");
strcat(bufor2, lpCmdLine);
execl(bufor, bufor, bufor2, NULL);
return 0;
}