5 #define PERL_NO_GET_CONTEXT
11 # define countof(array) (sizeof (array) / sizeof (*(array)))
14 #define SE_SHUTDOWN_NAMEA "SeShutdownPrivilege"
16 #ifndef WC_NO_BEST_FIT_CHARS
17 # define WC_NO_BEST_FIT_CHARS 0x00000400
20 #define GETPROC(fn) pfn##fn = (PFN##fn)GetProcAddress(module, #fn)
22 typedef BOOL (WINAPI *PFNSHGetSpecialFolderPathA)(HWND, char*, int, BOOL);
23 typedef BOOL (WINAPI *PFNSHGetSpecialFolderPathW)(HWND, WCHAR*, int, BOOL);
24 typedef HRESULT (WINAPI *PFNSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPTSTR);
25 typedef HRESULT (WINAPI *PFNSHGetFolderPathW)(HWND, int, HANDLE, DWORD, LPWSTR);
26 typedef BOOL (WINAPI *PFNCreateEnvironmentBlock)(void**, HANDLE, BOOL);
27 typedef BOOL (WINAPI *PFNDestroyEnvironmentBlock)(void*);
28 typedef int (__stdcall *PFNDllRegisterServer)(void);
29 typedef int (__stdcall *PFNDllUnregisterServer)(void);
30 typedef DWORD (__stdcall *PFNNetApiBufferFree)(void*);
31 typedef DWORD (__stdcall *PFNNetWkstaGetInfo)(LPWSTR, DWORD, void*);
33 typedef BOOL (__stdcall *PFNOpenProcessToken)(HANDLE, DWORD, HANDLE*);
34 typedef BOOL (__stdcall *PFNOpenThreadToken)(HANDLE, DWORD, BOOL, HANDLE*);
35 typedef BOOL (__stdcall *PFNGetTokenInformation)(HANDLE, TOKEN_INFORMATION_CLASS, void*, DWORD, DWORD*);
36 typedef BOOL (__stdcall *PFNAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD,
37 DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
38 typedef BOOL (__stdcall *PFNEqualSid)(PSID, PSID);
39 typedef void* (__stdcall *PFNFreeSid)(PSID);
40 typedef BOOL (__stdcall *PFNIsUserAnAdmin)(void);
43 # define CSIDL_MYMUSIC 0x000D
46 # define CSIDL_MYVIDEO 0x000E
48 #ifndef CSIDL_LOCAL_APPDATA
49 # define CSIDL_LOCAL_APPDATA 0x001C
51 #ifndef CSIDL_COMMON_FAVORITES
52 # define CSIDL_COMMON_FAVORITES 0x001F
54 #ifndef CSIDL_INTERNET_CACHE
55 # define CSIDL_INTERNET_CACHE 0x0020
58 # define CSIDL_COOKIES 0x0021
61 # define CSIDL_HISTORY 0x0022
63 #ifndef CSIDL_COMMON_APPDATA
64 # define CSIDL_COMMON_APPDATA 0x0023
67 # define CSIDL_WINDOWS 0x0024
69 #ifndef CSIDL_PROGRAM_FILES
70 # define CSIDL_PROGRAM_FILES 0x0026
72 #ifndef CSIDL_MYPICTURES
73 # define CSIDL_MYPICTURES 0x0027
76 # define CSIDL_PROFILE 0x0028
78 #ifndef CSIDL_PROGRAM_FILES_COMMON
79 # define CSIDL_PROGRAM_FILES_COMMON 0x002B
81 #ifndef CSIDL_COMMON_TEMPLATES
82 # define CSIDL_COMMON_TEMPLATES 0x002D
84 #ifndef CSIDL_COMMON_DOCUMENTS
85 # define CSIDL_COMMON_DOCUMENTS 0x002E
87 #ifndef CSIDL_COMMON_ADMINTOOLS
88 # define CSIDL_COMMON_ADMINTOOLS 0x002F
90 #ifndef CSIDL_ADMINTOOLS
91 # define CSIDL_ADMINTOOLS 0x0030
93 #ifndef CSIDL_COMMON_MUSIC
94 # define CSIDL_COMMON_MUSIC 0x0035
96 #ifndef CSIDL_COMMON_PICTURES
97 # define CSIDL_COMMON_PICTURES 0x0036
99 #ifndef CSIDL_COMMON_VIDEO
100 # define CSIDL_COMMON_VIDEO 0x0037
102 #ifndef CSIDL_CDBURN_AREA
103 # define CSIDL_CDBURN_AREA 0x003B
105 #ifndef CSIDL_FLAG_CREATE
106 # define CSIDL_FLAG_CREATE 0x8000
109 /* Use explicit struct definition because wSuiteMask and
110 * wProductType are not defined in the VC++ 6.0 headers.
111 * WORD type has been replaced by unsigned short because
112 * WORD is already used by Perl itself.
115 DWORD dwOSVersionInfoSize;
116 DWORD dwMajorVersion;
117 DWORD dwMinorVersion;
120 CHAR szCSDVersion[128];
121 unsigned short wServicePackMajor;
122 unsigned short wServicePackMinor;
123 unsigned short wSuiteMask;
126 } g_osver = {0, 0, 0, 0, 0, "", 0, 0, 0, 0, 0};
127 BOOL g_osver_ex = TRUE;
129 #define ONE_K_BUFSIZE 1024
134 return (g_osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
140 return (g_osver.dwPlatformId == VER_PLATFORM_WIN32_NT);
146 return (g_osver.dwMajorVersion > 4);
149 /* Convert SV to wide character string. The return value must be
150 * freed using Safefree().
153 sv_to_wstr(pTHX_ SV *sv)
158 char *str = SvPV(sv, len);
159 UINT cp = SvUTF8(sv) ? CP_UTF8 : CP_ACP;
161 wlen = MultiByteToWideChar(cp, 0, str, (int)(len+1), NULL, 0);
162 New(0, wstr, wlen, WCHAR);
163 MultiByteToWideChar(cp, 0, str, (int)(len+1), wstr, wlen);
168 /* Convert wide character string to mortal SV. Use UTF8 encoding
169 * if the string cannot be represented in the system codepage.
172 wstr_to_sv(pTHX_ WCHAR *wstr)
174 int wlen = (int)wcslen(wstr)+1;
175 BOOL use_default = FALSE;
176 int len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wstr, wlen, NULL, 0, NULL, NULL);
177 SV *sv = sv_2mortal(newSV(len));
179 len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wstr, wlen, SvPVX(sv), len, NULL, &use_default);
181 len = WideCharToMultiByte(CP_UTF8, 0, wstr, wlen, NULL, 0, NULL, NULL);
183 len = WideCharToMultiByte(CP_UTF8, 0, wstr, wlen, SvPVX(sv), len, NULL, NULL);
186 /* Shouldn't really ever fail since we ask for the required length first, but who knows... */
189 SvCUR_set(sv, len-1);
194 /* Retrieve a variable from the Unicode environment in a mortal SV.
196 * Recreates the Unicode environment because a bug in earlier Perl versions
197 * overwrites it with the ANSI version, which contains replacement
198 * characters for the characters not in the ANSI codepage.
201 get_unicode_env(pTHX_ WCHAR *name)
207 PFNOpenProcessToken pfnOpenProcessToken;
209 /* Get security token for the current process owner */
210 module = LoadLibrary("advapi32.dll");
214 GETPROC(OpenProcessToken);
216 if (pfnOpenProcessToken == NULL ||
217 !pfnOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_DUPLICATE, &token))
224 /* Create a Unicode environment block for this process */
225 module = LoadLibrary("userenv.dll");
227 PFNCreateEnvironmentBlock pfnCreateEnvironmentBlock;
228 PFNDestroyEnvironmentBlock pfnDestroyEnvironmentBlock;
230 GETPROC(CreateEnvironmentBlock);
231 GETPROC(DestroyEnvironmentBlock);
233 if (pfnCreateEnvironmentBlock && pfnDestroyEnvironmentBlock &&
234 pfnCreateEnvironmentBlock(&env, token, FALSE))
236 size_t name_len = wcslen(name);
240 size_t entry_len = wcslen(entry);
241 BOOL equal = (entry_len > name_len) && (entry[name_len] == '=');
243 for (i=0; equal && i < name_len; ++i)
244 equal = (towupper(entry[i]) == towupper(name[i]));
247 sv = wstr_to_sv(aTHX_ entry+name_len+1);
250 entry += entry_len+1;
252 pfnDestroyEnvironmentBlock(env);
260 /* Define both an ANSI and a Wide version of win32_longpath */
263 #define WIN32_FIND_DATA_T WIN32_FIND_DATAA
264 #define FN_FINDFIRSTFILE FindFirstFileA
265 #define FN_STRLEN strlen
266 #define FN_STRCPY strcpy
267 #define LONGPATH my_longpathA
268 #include "longpath.inc"
271 #define WIN32_FIND_DATA_T WIN32_FIND_DATAW
272 #define FN_FINDFIRSTFILE FindFirstFileW
273 #define FN_STRLEN wcslen
274 #define FN_STRCPY wcscpy
275 #define LONGPATH my_longpathW
276 #include "longpath.inc"
278 /* The my_ansipath() function takes a Unicode filename and converts it
279 * into the current Windows codepage. If some characters cannot be mapped,
280 * then it will convert the short name instead.
282 * The buffer to the ansi pathname must be freed with Safefree() when it
283 * it no longer needed.
285 * The argument to my_ansipath() must exist before this function is
286 * called; otherwise there is no way to determine the short path name.
288 * Ideas for future refinement:
289 * - Only convert those segments of the path that are not in the current
290 * codepage, but leave the other segments in their long form.
291 * - If the resulting name is longer than MAX_PATH, start converting
292 * additional path segments into short names until the full name
293 * is shorter than MAX_PATH. Shorten the filename part last!
296 /* This is a modified version of core Perl win32/win32.c(win32_ansipath).
297 * It uses New() etc. instead of win32_malloc().
301 my_ansipath(const WCHAR *widename)
304 BOOL use_default = FALSE;
305 int widelen = (int)wcslen(widename)+1;
306 int len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, widename, widelen,
307 NULL, 0, NULL, NULL);
308 New(0, name, len, char);
309 WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, widename, widelen,
310 name, len, NULL, &use_default);
312 DWORD shortlen = GetShortPathNameW(widename, NULL, 0);
315 New(0, shortname, shortlen, WCHAR);
316 shortlen = GetShortPathNameW(widename, shortname, shortlen)+1;
318 len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, shortname, shortlen,
319 NULL, 0, NULL, NULL);
320 Renew(name, len, char);
321 WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, shortname, shortlen,
322 name, len, NULL, NULL);
329 /* Convert wide character path to ANSI path and return as mortal SV. */
331 wstr_to_ansipath(pTHX_ WCHAR *wstr)
333 char *ansi = my_ansipath(wstr);
334 SV *sv = sv_2mortal(newSVpvn(ansi, strlen(ansi)));
348 WCHAR filename[MAX_PATH+1];
349 GetCurrentDirectoryW(MAX_PATH+1, filename);
350 ptr = my_ansipath(filename);
353 char filename[MAX_PATH+1];
354 GetCurrentDirectoryA(MAX_PATH+1, filename);
355 New(0, ptr, strlen(filename)+1, char);
356 strcpy(ptr, filename);
362 free_childdir(char *d)
375 free_childenv(void *d)
379 # define PerlDir_mapA(dir) (dir)
383 XS(w32_ExpandEnvironmentStrings)
388 croak("usage: Win32::ExpandEnvironmentStrings($String);\n");
391 WCHAR value[31*1024];
392 WCHAR *source = sv_to_wstr(aTHX_ ST(0));
393 ExpandEnvironmentStringsW(source, value, countof(value)-1);
394 ST(0) = wstr_to_sv(aTHX_ value);
400 ExpandEnvironmentStringsA(SvPV_nolen(ST(0)), value, countof(value)-2);
409 PFNIsUserAnAdmin pfnIsUserAnAdmin;
410 PFNOpenThreadToken pfnOpenThreadToken;
411 PFNOpenProcessToken pfnOpenProcessToken;
412 PFNGetTokenInformation pfnGetTokenInformation;
413 PFNAllocateAndInitializeSid pfnAllocateAndInitializeSid;
414 PFNEqualSid pfnEqualSid;
415 PFNFreeSid pfnFreeSid;
418 TOKEN_GROUPS *lpTokInfo;
419 SID_IDENTIFIER_AUTHORITY NtAuth = SECURITY_NT_AUTHORITY;
425 croak("usage: Win32::IsAdminUser()");
427 /* There is no concept of "Administrator" user accounts on Win9x systems,
428 so just return true. */
432 /* Use IsUserAnAdmin() when available. On Vista this will only return TRUE
433 * if the process is running with elevated privileges and not just when the
434 * process owner is a member of the "Administrators" group.
436 module = LoadLibrary("shell32.dll");
438 GETPROC(IsUserAnAdmin);
439 if (pfnIsUserAnAdmin) {
441 ST(0) = sv_2mortal(newSViv(pfnIsUserAnAdmin() ? 1 : 0));
448 module = LoadLibrary("advapi32.dll");
450 warn("Cannot load advapi32.dll library");
454 GETPROC(OpenThreadToken);
455 GETPROC(OpenProcessToken);
456 GETPROC(GetTokenInformation);
457 GETPROC(AllocateAndInitializeSid);
461 if (!(pfnOpenThreadToken && pfnOpenProcessToken &&
462 pfnGetTokenInformation && pfnAllocateAndInitializeSid &&
463 pfnEqualSid && pfnFreeSid))
465 warn("Cannot load functions from advapi32.dll library");
470 if (!pfnOpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE, &hTok)) {
471 if (!pfnOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hTok)) {
472 warn("Cannot open thread token or process token");
478 pfnGetTokenInformation(hTok, TokenGroups, NULL, 0, &dwTokInfoLen);
479 if (!New(1, lpTokInfo, dwTokInfoLen, TOKEN_GROUPS)) {
480 warn("Cannot allocate token information structure");
486 if (!pfnGetTokenInformation(hTok, TokenGroups, lpTokInfo, dwTokInfoLen,
489 warn("Cannot get token information");
496 if (!pfnAllocateAndInitializeSid(&NtAuth, 2, SECURITY_BUILTIN_DOMAIN_RID,
497 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pAdminSid))
499 warn("Cannot allocate administrators' SID");
507 for (i = 0; i < lpTokInfo->GroupCount; ++i) {
508 if (pfnEqualSid(lpTokInfo->Groups[i].Sid, pAdminSid)) {
514 pfnFreeSid(pAdminSid);
520 ST(0) = sv_2mortal(newSViv(iRetVal));
524 XS(w32_LookupAccountName)
535 croak("usage: Win32::LookupAccountName($system, $account, $domain, "
536 "$sid, $sidtype);\n");
538 SIDLen = sizeof(SID);
539 DomLen = sizeof(Domain);
541 bResult = LookupAccountNameA(SvPV_nolen(ST(0)), /* System */
542 SvPV_nolen(ST(1)), /* Account name */
543 &SID, /* SID structure */
544 &SIDLen, /* Size of SID buffer */
545 Domain, /* Domain buffer */
546 &DomLen, /* Domain buffer size */
547 &snu); /* SID name type */
549 sv_setpv(ST(2), Domain);
550 sv_setpvn(ST(3), SID, SIDLen);
551 sv_setiv(ST(4), snu);
558 XS(w32_LookupAccountSID)
563 DWORD AcctLen = sizeof(Account);
565 DWORD DomLen = sizeof(Domain);
570 croak("usage: Win32::LookupAccountSID($system, $sid, $account, $domain, $sidtype);\n");
572 sid = SvPV_nolen(ST(1));
573 if (IsValidSid(sid)) {
574 bResult = LookupAccountSidA(SvPV_nolen(ST(0)), /* System */
575 sid, /* SID structure */
576 Account, /* Account name buffer */
577 &AcctLen, /* name buffer length */
578 Domain, /* Domain buffer */
579 &DomLen, /* Domain buffer length */
580 &snu); /* SID name type */
582 sv_setpv(ST(2), Account);
583 sv_setpv(ST(3), Domain);
584 sv_setiv(ST(4), (IV)snu);
591 XS(w32_InitiateSystemShutdown)
594 HANDLE hToken; /* handle to process token */
595 TOKEN_PRIVILEGES tkp; /* pointer to token structure */
597 char *machineName, *message;
600 croak("usage: Win32::InitiateSystemShutdown($machineName, $message, "
601 "$timeOut, $forceClose, $reboot);\n");
603 machineName = SvPV_nolen(ST(0));
605 if (OpenProcessToken(GetCurrentProcess(),
606 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
609 LookupPrivilegeValueA(machineName,
611 &tkp.Privileges[0].Luid);
613 tkp.PrivilegeCount = 1; /* only setting one */
614 tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
616 /* Get shutdown privilege for this process. */
617 AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
618 (PTOKEN_PRIVILEGES)NULL, 0);
621 message = SvPV_nolen(ST(1));
622 bRet = InitiateSystemShutdownA(machineName, message, (DWORD)SvIV(ST(2)),
623 (BOOL)SvIV(ST(3)), (BOOL)SvIV(ST(4)));
625 /* Disable shutdown privilege. */
626 tkp.Privileges[0].Attributes = 0;
627 AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
628 (PTOKEN_PRIVILEGES)NULL, 0);
633 XS(w32_AbortSystemShutdown)
636 HANDLE hToken; /* handle to process token */
637 TOKEN_PRIVILEGES tkp; /* pointer to token structure */
642 croak("usage: Win32::AbortSystemShutdown($machineName);\n");
644 machineName = SvPV_nolen(ST(0));
646 if (OpenProcessToken(GetCurrentProcess(),
647 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
650 LookupPrivilegeValueA(machineName,
652 &tkp.Privileges[0].Luid);
654 tkp.PrivilegeCount = 1; /* only setting one */
655 tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
657 /* Get shutdown privilege for this process. */
658 AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
659 (PTOKEN_PRIVILEGES)NULL, 0);
662 bRet = AbortSystemShutdownA(machineName);
664 /* Disable shutdown privilege. */
665 tkp.Privileges[0].Attributes = 0;
666 AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
667 (PTOKEN_PRIVILEGES)NULL, 0);
676 DWORD flags = MB_ICONEXCLAMATION;
679 if (items < 1 || items > 3)
680 croak("usage: Win32::MsgBox($message [, $flags [, $title]]);\n");
683 flags = (DWORD)SvIV(ST(1));
687 WCHAR *msg = sv_to_wstr(aTHX_ ST(0));
689 title = sv_to_wstr(aTHX_ ST(2));
690 result = MessageBoxW(GetActiveWindow(), msg, title ? title : L"Perl", flags);
696 char *title = "Perl";
697 char *msg = SvPV_nolen(ST(0));
699 title = SvPV_nolen(ST(2));
700 result = MessageBoxA(GetActiveWindow(), msg, title, flags);
711 croak("usage: Win32::LoadLibrary($libname)\n");
712 hHandle = LoadLibraryA(SvPV_nolen(ST(0)));
714 XSRETURN_IV((DWORD_PTR)hHandle);
716 XSRETURN_IV((DWORD)hHandle);
725 croak("usage: Win32::FreeLibrary($handle)\n");
726 if (FreeLibrary(INT2PTR(HINSTANCE, SvIV(ST(0))))) {
732 XS(w32_GetProcAddress)
737 croak("usage: Win32::GetProcAddress($hinstance, $procname)\n");
738 XSRETURN_IV(PTR2IV(GetProcAddress(INT2PTR(HINSTANCE, SvIV(ST(0))), SvPV_nolen(ST(1)))));
741 XS(w32_RegisterServer)
748 croak("usage: Win32::RegisterServer($libname)\n");
750 module = LoadLibraryA(SvPV_nolen(ST(0)));
752 PFNDllRegisterServer pfnDllRegisterServer;
753 GETPROC(DllRegisterServer);
754 if (pfnDllRegisterServer && pfnDllRegisterServer() == 0)
758 ST(0) = boolSV(result);
762 XS(w32_UnregisterServer)
769 croak("usage: Win32::UnregisterServer($libname)\n");
771 module = LoadLibraryA(SvPV_nolen(ST(0)));
773 PFNDllUnregisterServer pfnDllUnregisterServer;
774 GETPROC(DllUnregisterServer);
775 if (pfnDllUnregisterServer && pfnDllUnregisterServer() == 0)
779 ST(0) = boolSV(result);
783 /* XXX rather bogus */
787 XSRETURN_PV(getenv("PROCESSOR_ARCHITECTURE"));
795 Zero(&sysinfo,1,SYSTEM_INFO);
796 GetSystemInfo(&sysinfo);
797 /* XXX docs say dwProcessorType is deprecated on NT */
798 XSRETURN_IV(sysinfo.dwProcessorType);
805 char szGUID[50] = {'\0'};
806 HRESULT hr = CoCreateGuid(&guid);
809 LPOLESTR pStr = NULL;
810 if (SUCCEEDED(StringFromCLSID(&guid, &pStr))) {
811 WideCharToMultiByte(CP_ACP, 0, pStr, (int)wcslen(pStr), szGUID,
812 sizeof(szGUID), NULL, NULL);
820 XS(w32_GetFolderPath)
823 char path[MAX_PATH+1];
824 WCHAR wpath[MAX_PATH+1];
829 if (items != 1 && items != 2)
830 croak("usage: Win32::GetFolderPath($csidl [, $create])\n");
832 folder = (int)SvIV(ST(0));
834 create = SvTRUE(ST(1)) ? CSIDL_FLAG_CREATE : 0;
836 module = LoadLibrary("shfolder.dll");
838 PFNSHGetFolderPathA pfna;
840 PFNSHGetFolderPathW pfnw;
841 pfnw = (PFNSHGetFolderPathW)GetProcAddress(module, "SHGetFolderPathW");
842 if (pfnw && SUCCEEDED(pfnw(NULL, folder|create, NULL, 0, wpath))) {
844 ST(0) = wstr_to_ansipath(aTHX_ wpath);
848 pfna = (PFNSHGetFolderPathA)GetProcAddress(module, "SHGetFolderPathA");
849 if (pfna && SUCCEEDED(pfna(NULL, folder|create, NULL, 0, path))) {
856 module = LoadLibrary("shell32.dll");
858 PFNSHGetSpecialFolderPathA pfna;
860 PFNSHGetSpecialFolderPathW pfnw;
861 pfnw = (PFNSHGetSpecialFolderPathW)GetProcAddress(module, "SHGetSpecialFolderPathW");
862 if (pfnw && pfnw(NULL, wpath, folder, !!create)) {
864 ST(0) = wstr_to_ansipath(aTHX_ wpath);
868 pfna = (PFNSHGetSpecialFolderPathA)GetProcAddress(module, "SHGetSpecialFolderPathA");
869 if (pfna && pfna(NULL, path, folder, !!create)) {
876 /* SHGetFolderPathW() and SHGetSpecialFolderPathW() may fail on older
877 * Perl versions that have replaced the Unicode environment with an
878 * ANSI version. Let's go spelunking in the registry now...
883 HKEY root = HKEY_CURRENT_USER;
887 case CSIDL_ADMINTOOLS: name = L"Administrative Tools"; break;
888 case CSIDL_APPDATA: name = L"AppData"; break;
889 case CSIDL_CDBURN_AREA: name = L"CD Burning"; break;
890 case CSIDL_COOKIES: name = L"Cookies"; break;
892 case CSIDL_DESKTOPDIRECTORY: name = L"Desktop"; break;
893 case CSIDL_FAVORITES: name = L"Favorites"; break;
894 case CSIDL_FONTS: name = L"Fonts"; break;
895 case CSIDL_HISTORY: name = L"History"; break;
896 case CSIDL_INTERNET_CACHE: name = L"Cache"; break;
897 case CSIDL_LOCAL_APPDATA: name = L"Local AppData"; break;
898 case CSIDL_MYMUSIC: name = L"My Music"; break;
899 case CSIDL_MYPICTURES: name = L"My Pictures"; break;
900 case CSIDL_MYVIDEO: name = L"My Video"; break;
901 case CSIDL_NETHOOD: name = L"NetHood"; break;
902 case CSIDL_PERSONAL: name = L"Personal"; break;
903 case CSIDL_PRINTHOOD: name = L"PrintHood"; break;
904 case CSIDL_PROGRAMS: name = L"Programs"; break;
905 case CSIDL_RECENT: name = L"Recent"; break;
906 case CSIDL_SENDTO: name = L"SendTo"; break;
907 case CSIDL_STARTMENU: name = L"Start Menu"; break;
908 case CSIDL_STARTUP: name = L"Startup"; break;
909 case CSIDL_TEMPLATES: name = L"Templates"; break;
910 /* XXX L"Local Settings" */
914 root = HKEY_LOCAL_MACHINE;
916 case CSIDL_COMMON_ADMINTOOLS: name = L"Common Administrative Tools"; break;
917 case CSIDL_COMMON_APPDATA: name = L"Common AppData"; break;
918 case CSIDL_COMMON_DESKTOPDIRECTORY: name = L"Common Desktop"; break;
919 case CSIDL_COMMON_DOCUMENTS: name = L"Common Documents"; break;
920 case CSIDL_COMMON_FAVORITES: name = L"Common Favorites"; break;
921 case CSIDL_COMMON_PROGRAMS: name = L"Common Programs"; break;
922 case CSIDL_COMMON_STARTMENU: name = L"Common Start Menu"; break;
923 case CSIDL_COMMON_STARTUP: name = L"Common Startup"; break;
924 case CSIDL_COMMON_TEMPLATES: name = L"Common Templates"; break;
925 case CSIDL_COMMON_MUSIC: name = L"CommonMusic"; break;
926 case CSIDL_COMMON_PICTURES: name = L"CommonPictures"; break;
927 case CSIDL_COMMON_VIDEO: name = L"CommonVideo"; break;
931 * case CSIDL_SYSTEM # GetSystemDirectory()
932 * case CSIDL_RESOURCES # %windir%\Resources\, For theme and other windows resources.
933 * case CSIDL_RESOURCES_LOCALIZED # %windir%\Resources\<LangID>, for theme and other windows specific resources.
936 #define SHELL_FOLDERS "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
938 if (name && RegOpenKeyEx(root, SHELL_FOLDERS, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) {
939 WCHAR data[MAX_PATH+1];
940 DWORD cb = sizeof(data)-sizeof(WCHAR);
941 DWORD type = REG_NONE;
942 long rc = RegQueryValueExW(hkey, name, NULL, &type, (BYTE*)&data, &cb);
944 if (rc == ERROR_SUCCESS && type == REG_SZ && cb > sizeof(WCHAR) && data[0]) {
945 /* Make sure the string is properly terminated */
946 data[cb/sizeof(WCHAR)] = '\0';
947 ST(0) = wstr_to_ansipath(aTHX_ data);
954 /* Unders some circumstances the registry entries seem to have a null string
955 * as their value even when the directory already exists. The environment
956 * variables do get set though, so try re-create a Unicode environment and
957 * check if they are there.
961 case CSIDL_APPDATA: sv = get_unicode_env(aTHX_ L"APPDATA"); break;
962 case CSIDL_PROFILE: sv = get_unicode_env(aTHX_ L"USERPROFILE"); break;
963 case CSIDL_PROGRAM_FILES: sv = get_unicode_env(aTHX_ L"ProgramFiles"); break;
964 case CSIDL_PROGRAM_FILES_COMMON: sv = get_unicode_env(aTHX_ L"CommonProgramFiles"); break;
965 case CSIDL_WINDOWS: sv = get_unicode_env(aTHX_ L"SystemRoot"); break;
976 XS(w32_GetFileVersion)
985 croak("usage: Win32::GetFileVersion($filename)\n");
987 filename = SvPV_nolen(ST(0));
988 size = GetFileVersionInfoSize(filename, &handle);
992 New(0, data, size, char);
996 if (GetFileVersionInfo(filename, handle, size, data)) {
997 VS_FIXEDFILEINFO *info;
999 if (VerQueryValue(data, "\\", (void**)&info, &len)) {
1000 int dwValueMS1 = (info->dwFileVersionMS>>16);
1001 int dwValueMS2 = (info->dwFileVersionMS&0xffff);
1002 int dwValueLS1 = (info->dwFileVersionLS>>16);
1003 int dwValueLS2 = (info->dwFileVersionLS&0xffff);
1005 if (GIMME_V == G_ARRAY) {
1007 XST_mIV(0, dwValueMS1);
1008 XST_mIV(1, dwValueMS2);
1009 XST_mIV(2, dwValueLS1);
1010 XST_mIV(3, dwValueLS2);
1015 sprintf(version, "%d.%d.%d.%d", dwValueMS1, dwValueMS2, dwValueLS1, dwValueLS2);
1016 XST_mPV(0, version);
1028 XS(w32_SetChildShowWindow)
1030 /* This function doesn't do anything useful for cygwin. In the
1031 * MSWin32 case it modifies w32_showwindow, which is used by
1032 * win32_spawnvp(). Since w32_showwindow is an internal variable
1033 * inside the thread_intern structure, the MSWin32 implementation
1034 * lives in win32/win32.c in the core Perl distribution.
1044 /* Make the host for current directory */
1045 char* ptr = PerlEnv_get_childdir();
1048 * then it worked, set PV valid,
1049 * else return 'undef'
1052 SV *sv = sv_newmortal();
1054 PerlEnv_free_childdir(ptr);
1056 #ifndef INCOMPLETE_TAINTS
1071 Perl_croak(aTHX_ "usage: Win32::SetCwd($cwd)");
1073 if (IsWin2000() && SvUTF8(ST(0))) {
1074 WCHAR *wide = sv_to_wstr(aTHX_ ST(0));
1075 char *ansi = my_ansipath(wide);
1076 int rc = PerlDir_chdir(ansi);
1083 if (!PerlDir_chdir(SvPV_nolen(ST(0))))
1090 XS(w32_GetNextAvailDrive)
1094 char root[] = "_:\\";
1099 if (GetDriveType(root) == 1) {
1107 XS(w32_GetLastError)
1111 XSRETURN_IV(GetLastError());
1114 XS(w32_SetLastError)
1118 Perl_croak(aTHX_ "usage: Win32::SetLastError($error)");
1119 SetLastError((DWORD)SvIV(ST(0)));
1129 DWORD size = countof(name);
1130 if (GetUserNameW(name, &size)) {
1131 ST(0) = wstr_to_sv(aTHX_ name);
1137 DWORD size = countof(name);
1138 if (GetUserNameA(name, &size)) {
1139 /* size includes NULL */
1140 ST(0) = sv_2mortal(newSVpvn(name, size-1));
1150 char name[MAX_COMPUTERNAME_LENGTH+1];
1151 DWORD size = sizeof(name);
1153 if (GetComputerName(name,&size)) {
1154 /* size does NOT include NULL :-( */
1155 ST(0) = sv_2mortal(newSVpvn(name,size));
1165 HMODULE module = LoadLibrary("netapi32.dll");
1166 PFNNetApiBufferFree pfnNetApiBufferFree;
1167 PFNNetWkstaGetInfo pfnNetWkstaGetInfo;
1170 GETPROC(NetApiBufferFree);
1171 GETPROC(NetWkstaGetInfo);
1174 if (module && pfnNetWkstaGetInfo && pfnNetApiBufferFree) {
1175 /* this way is more reliable, in case user has a local account. */
1177 DWORD dnamelen = sizeof(dname);
1179 DWORD wki100_platform_id;
1180 LPWSTR wki100_computername;
1181 LPWSTR wki100_langroup;
1182 DWORD wki100_ver_major;
1183 DWORD wki100_ver_minor;
1186 retval = pfnNetWkstaGetInfo(NULL, 100, &pwi);
1187 /* NERR_Success *is* 0*/
1189 if (pwi->wki100_langroup && *(pwi->wki100_langroup)) {
1190 WideCharToMultiByte(CP_ACP, 0, pwi->wki100_langroup,
1191 -1, (LPSTR)dname, dnamelen, NULL, NULL);
1194 WideCharToMultiByte(CP_ACP, 0, pwi->wki100_computername,
1195 -1, (LPSTR)dname, dnamelen, NULL, NULL);
1197 pfnNetApiBufferFree(pwi);
1198 FreeLibrary(module);
1201 FreeLibrary(module);
1202 SetLastError(retval);
1205 /* Win95 doesn't have NetWksta*(), so do it the old way */
1207 DWORD size = sizeof(name);
1209 FreeLibrary(module);
1210 if (GetUserName(name,&size)) {
1211 char sid[ONE_K_BUFSIZE];
1212 DWORD sidlen = sizeof(sid);
1214 DWORD dnamelen = sizeof(dname);
1216 if (LookupAccountName(NULL, name, (PSID)&sid, &sidlen,
1217 dname, &dnamelen, &snu)) {
1218 XSRETURN_PV(dname); /* all that for this */
1229 DWORD flags, filecomplen;
1230 if (GetVolumeInformation(NULL, NULL, 0, NULL, &filecomplen,
1231 &flags, fsname, sizeof(fsname))) {
1232 if (GIMME_V == G_ARRAY) {
1233 XPUSHs(sv_2mortal(newSVpvn(fsname,strlen(fsname))));
1234 XPUSHs(sv_2mortal(newSViv(flags)));
1235 XPUSHs(sv_2mortal(newSViv(filecomplen)));
1240 XSRETURN_PV(fsname);
1245 XS(w32_GetOSVersion)
1249 if (GIMME_V == G_SCALAR) {
1250 XSRETURN_IV(g_osver.dwPlatformId);
1252 XPUSHs(sv_2mortal(newSVpvn(g_osver.szCSDVersion, strlen(g_osver.szCSDVersion))));
1254 XPUSHs(sv_2mortal(newSViv(g_osver.dwMajorVersion)));
1255 XPUSHs(sv_2mortal(newSViv(g_osver.dwMinorVersion)));
1256 XPUSHs(sv_2mortal(newSViv(g_osver.dwBuildNumber)));
1257 XPUSHs(sv_2mortal(newSViv(g_osver.dwPlatformId)));
1259 XPUSHs(sv_2mortal(newSViv(g_osver.wServicePackMajor)));
1260 XPUSHs(sv_2mortal(newSViv(g_osver.wServicePackMinor)));
1261 XPUSHs(sv_2mortal(newSViv(g_osver.wSuiteMask)));
1262 XPUSHs(sv_2mortal(newSViv(g_osver.wProductType)));
1271 XSRETURN_IV(IsWinNT());
1278 XSRETURN_IV(IsWin95());
1281 XS(w32_FormatMessage)
1285 char msgbuf[ONE_K_BUFSIZE];
1288 Perl_croak(aTHX_ "usage: Win32::FormatMessage($errno)");
1290 if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM,
1291 &source, (DWORD)SvIV(ST(0)), 0,
1292 msgbuf, sizeof(msgbuf)-1, NULL))
1294 XSRETURN_PV(msgbuf);
1306 PROCESS_INFORMATION stProcInfo;
1307 STARTUPINFO stStartInfo;
1308 BOOL bSuccess = FALSE;
1311 Perl_croak(aTHX_ "usage: Win32::Spawn($cmdName, $args, $PID)");
1313 cmd = SvPV_nolen(ST(0));
1314 args = SvPV_nolen(ST(1));
1316 env = PerlEnv_get_childenv();
1317 dir = PerlEnv_get_childdir();
1319 memset(&stStartInfo, 0, sizeof(stStartInfo)); /* Clear the block */
1320 stStartInfo.cb = sizeof(stStartInfo); /* Set the structure size */
1321 stStartInfo.dwFlags = STARTF_USESHOWWINDOW; /* Enable wShowWindow control */
1322 stStartInfo.wShowWindow = SW_SHOWMINNOACTIVE; /* Start min (normal) */
1325 cmd, /* Image path */
1326 args, /* Arguments for command line */
1327 NULL, /* Default process security */
1328 NULL, /* Default thread security */
1329 FALSE, /* Must be TRUE to use std handles */
1330 NORMAL_PRIORITY_CLASS, /* No special scheduling */
1331 env, /* Inherit our environment block */
1332 dir, /* Inherit our currrent directory */
1333 &stStartInfo, /* -> Startup info */
1334 &stProcInfo)) /* <- Process info (if OK) */
1336 int pid = (int)stProcInfo.dwProcessId;
1337 if (IsWin95() && pid < 0)
1339 sv_setiv(ST(2), pid);
1340 CloseHandle(stProcInfo.hThread);/* library source code does this. */
1343 PerlEnv_free_childenv(env);
1344 PerlEnv_free_childdir(dir);
1345 XSRETURN_IV(bSuccess);
1348 XS(w32_GetTickCount)
1351 DWORD msec = GetTickCount();
1358 XS(w32_GetShortPathName)
1365 Perl_croak(aTHX_ "usage: Win32::GetShortPathName($longPathName)");
1368 WCHAR wshort[MAX_PATH+1];
1369 WCHAR *wlong = sv_to_wstr(aTHX_ ST(0));
1370 len = GetShortPathNameW(wlong, wshort, countof(wshort));
1372 if (len && len < sizeof(wshort)) {
1373 ST(0) = wstr_to_sv(aTHX_ wshort);
1379 shortpath = sv_mortalcopy(ST(0));
1380 SvUPGRADE(shortpath, SVt_PV);
1381 if (!SvPVX(shortpath) || !SvLEN(shortpath))
1384 /* src == target is allowed */
1386 len = GetShortPathName(SvPVX(shortpath),
1388 (DWORD)SvLEN(shortpath));
1389 } while (len >= SvLEN(shortpath) && sv_grow(shortpath,len+1));
1391 SvCUR_set(shortpath,len);
1392 *SvEND(shortpath) = '\0';
1399 XS(w32_GetFullPathName)
1405 /* The code below relies on the fact that PerlDir_mapX() returns an
1406 * absolute path, which is only true under PERL_IMPLICIT_SYS when
1407 * we use the virtualization code from win32/vdir.h.
1408 * Without it PerlDir_mapX() is a no-op and we need to use the same
1409 * code as we use for Cygwin.
1411 #if __CYGWIN__ || !defined(PERL_IMPLICIT_SYS)
1412 char buffer[2*MAX_PATH];
1416 Perl_croak(aTHX_ "usage: Win32::GetFullPathName($filename)");
1418 #if __CYGWIN__ || !defined(PERL_IMPLICIT_SYS)
1420 WCHAR *filename = sv_to_wstr(aTHX_ ST(0));
1421 WCHAR full[2*MAX_PATH];
1422 DWORD len = GetFullPathNameW(filename, countof(full), full, NULL);
1424 if (len == 0 || len >= countof(full))
1426 ansi = fullname = my_ansipath(full);
1429 DWORD len = GetFullPathNameA(SvPV_nolen(ST(0)), countof(buffer), buffer, NULL);
1430 if (len == 0 || len >= countof(buffer))
1435 /* Don't use my_ansipath() unless the $filename argument is in Unicode.
1436 * If the relative path doesn't exist, GetShortPathName() will fail and
1437 * my_ansipath() will use the long name with replacement characters.
1438 * In that case we will be better off using PerlDir_mapA(), which
1439 * already uses the ANSI name of the current directory.
1441 * XXX The one missing case is where we could downgrade $filename
1442 * XXX from UTF8 into the current codepage.
1444 if (IsWin2000() && SvUTF8(ST(0))) {
1445 WCHAR *filename = sv_to_wstr(aTHX_ ST(0));
1446 WCHAR *mappedname = PerlDir_mapW(filename);
1448 ansi = fullname = my_ansipath(mappedname);
1451 fullname = PerlDir_mapA(SvPV_nolen(ST(0)));
1453 # if PERL_VERSION < 8
1455 /* PerlDir_mapX() in Perl 5.6 used to return forward slashes */
1456 char *str = fullname;
1466 /* GetFullPathName() on Windows NT drops trailing backslash */
1467 if (g_osver.dwMajorVersion == 4 && *fullname) {
1469 char *pv = SvPV(ST(0), len);
1470 char *lastchar = fullname + strlen(fullname) - 1;
1471 /* If ST(0) ends with a slash, but fullname doesn't ... */
1472 if (len && (pv[len-1] == '/' || pv[len-1] == '\\') && *lastchar != '\\') {
1473 /* fullname is the MAX_PATH+1 sized buffer returned from PerlDir_mapA()
1474 * or the 2*MAX_PATH sized local buffer in the __CYGWIN__ case.
1476 strcpy(lastchar+1, "\\");
1480 if (GIMME_V == G_ARRAY) {
1481 char *filepart = strrchr(fullname, '\\');
1485 XST_mPV(1, ++filepart);
1493 XST_mPV(0, fullname);
1500 XS(w32_GetLongPathName)
1505 Perl_croak(aTHX_ "usage: Win32::GetLongPathName($pathname)");
1508 WCHAR *wstr = sv_to_wstr(aTHX_ ST(0));
1509 WCHAR wide_path[MAX_PATH+1];
1512 wcscpy(wide_path, wstr);
1514 long_path = my_longpathW(wide_path);
1516 ST(0) = wstr_to_sv(aTHX_ long_path);
1522 char tmpbuf[MAX_PATH+1];
1527 pathstr = SvPV(path,len);
1528 strcpy(tmpbuf, pathstr);
1529 pathstr = my_longpathA(tmpbuf);
1531 ST(0) = sv_2mortal(newSVpvn(pathstr, strlen(pathstr)));
1538 XS(w32_GetANSIPathName)
1544 Perl_croak(aTHX_ "usage: Win32::GetANSIPathName($pathname)");
1546 wide_path = sv_to_wstr(aTHX_ ST(0));
1547 ST(0) = wstr_to_ansipath(aTHX_ wide_path);
1548 Safefree(wide_path);
1556 Perl_croak(aTHX_ "usage: Win32::Sleep($milliseconds)");
1557 Sleep((DWORD)SvIV(ST(0)));
1565 char szSourceFile[MAX_PATH+1];
1568 Perl_croak(aTHX_ "usage: Win32::CopyFile($from, $to, $overwrite)");
1569 strcpy(szSourceFile, PerlDir_mapA(SvPV_nolen(ST(0))));
1570 bResult = CopyFileA(szSourceFile, PerlDir_mapA(SvPV_nolen(ST(1))), !SvTRUE(ST(2)));
1576 XS(w32_OutputDebugString)
1580 Perl_croak(aTHX_ "usage: Win32::OutputDebugString($string)");
1582 if (SvUTF8(ST(0))) {
1583 WCHAR *str = sv_to_wstr(aTHX_ ST(0));
1584 OutputDebugStringW(str);
1588 OutputDebugStringA(SvPV_nolen(ST(0)));
1593 XS(w32_GetCurrentProcessId)
1597 XSRETURN_IV(GetCurrentProcessId());
1600 XS(w32_GetCurrentThreadId)
1604 XSRETURN_IV(GetCurrentThreadId());
1607 XS(w32_CreateDirectory)
1613 Perl_croak(aTHX_ "usage: Win32::CreateDirectory($dir)");
1615 if (IsWin2000() && SvUTF8(ST(0))) {
1616 WCHAR *dir = sv_to_wstr(aTHX_ ST(0));
1617 result = CreateDirectoryW(dir, NULL);
1621 result = CreateDirectoryA(SvPV_nolen(ST(0)), NULL);
1624 ST(0) = boolSV(result);
1634 Perl_croak(aTHX_ "usage: Win32::CreateFile($file)");
1636 if (IsWin2000() && SvUTF8(ST(0))) {
1637 WCHAR *file = sv_to_wstr(aTHX_ ST(0));
1638 handle = CreateFileW(file, GENERIC_WRITE, FILE_SHARE_WRITE,
1639 NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
1643 handle = CreateFileA(SvPV_nolen(ST(0)), GENERIC_WRITE, FILE_SHARE_WRITE,
1644 NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
1647 if (handle != INVALID_HANDLE_VALUE)
1648 CloseHandle(handle);
1650 ST(0) = boolSV(handle != INVALID_HANDLE_VALUE);
1654 MODULE = Win32 PACKAGE = Win32
1660 char *file = __FILE__;
1662 if (g_osver.dwOSVersionInfoSize == 0) {
1663 g_osver.dwOSVersionInfoSize = sizeof(g_osver);
1664 if (!GetVersionExA((OSVERSIONINFOA*)&g_osver)) {
1666 g_osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
1667 GetVersionExA((OSVERSIONINFOA*)&g_osver);
1671 newXS("Win32::LookupAccountName", w32_LookupAccountName, file);
1672 newXS("Win32::LookupAccountSID", w32_LookupAccountSID, file);
1673 newXS("Win32::InitiateSystemShutdown", w32_InitiateSystemShutdown, file);
1674 newXS("Win32::AbortSystemShutdown", w32_AbortSystemShutdown, file);
1675 newXS("Win32::ExpandEnvironmentStrings", w32_ExpandEnvironmentStrings, file);
1676 newXS("Win32::MsgBox", w32_MsgBox, file);
1677 newXS("Win32::LoadLibrary", w32_LoadLibrary, file);
1678 newXS("Win32::FreeLibrary", w32_FreeLibrary, file);
1679 newXS("Win32::GetProcAddress", w32_GetProcAddress, file);
1680 newXS("Win32::RegisterServer", w32_RegisterServer, file);
1681 newXS("Win32::UnregisterServer", w32_UnregisterServer, file);
1682 newXS("Win32::GetArchName", w32_GetArchName, file);
1683 newXS("Win32::GetChipName", w32_GetChipName, file);
1684 newXS("Win32::GuidGen", w32_GuidGen, file);
1685 newXS("Win32::GetFolderPath", w32_GetFolderPath, file);
1686 newXS("Win32::IsAdminUser", w32_IsAdminUser, file);
1687 newXS("Win32::GetFileVersion", w32_GetFileVersion, file);
1689 newXS("Win32::GetCwd", w32_GetCwd, file);
1690 newXS("Win32::SetCwd", w32_SetCwd, file);
1691 newXS("Win32::GetNextAvailDrive", w32_GetNextAvailDrive, file);
1692 newXS("Win32::GetLastError", w32_GetLastError, file);
1693 newXS("Win32::SetLastError", w32_SetLastError, file);
1694 newXS("Win32::LoginName", w32_LoginName, file);
1695 newXS("Win32::NodeName", w32_NodeName, file);
1696 newXS("Win32::DomainName", w32_DomainName, file);
1697 newXS("Win32::FsType", w32_FsType, file);
1698 newXS("Win32::GetOSVersion", w32_GetOSVersion, file);
1699 newXS("Win32::IsWinNT", w32_IsWinNT, file);
1700 newXS("Win32::IsWin95", w32_IsWin95, file);
1701 newXS("Win32::FormatMessage", w32_FormatMessage, file);
1702 newXS("Win32::Spawn", w32_Spawn, file);
1703 newXS("Win32::GetTickCount", w32_GetTickCount, file);
1704 newXS("Win32::GetShortPathName", w32_GetShortPathName, file);
1705 newXS("Win32::GetFullPathName", w32_GetFullPathName, file);
1706 newXS("Win32::GetLongPathName", w32_GetLongPathName, file);
1707 newXS("Win32::GetANSIPathName", w32_GetANSIPathName, file);
1708 newXS("Win32::CopyFile", w32_CopyFile, file);
1709 newXS("Win32::Sleep", w32_Sleep, file);
1710 newXS("Win32::OutputDebugString", w32_OutputDebugString, file);
1711 newXS("Win32::GetCurrentProcessId", w32_GetCurrentProcessId, file);
1712 newXS("Win32::GetCurrentThreadId", w32_GetCurrentThreadId, file);
1713 newXS("Win32::CreateDirectory", w32_CreateDirectory, file);
1714 newXS("Win32::CreateFile", w32_CreateFile, file);
1716 newXS("Win32::SetChildShowWindow", w32_SetChildShowWindow, file);