DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
typedef BOOL (__stdcall *PFNEqualSid)(PSID, PSID);
typedef void* (__stdcall *PFNFreeSid)(PSID);
-typedef BOOL (__stdcall *PFNIsUserAnAdmin)();
+typedef BOOL (__stdcall *PFNIsUserAnAdmin)(void);
#ifndef CSIDL_MYMUSIC
# define CSIDL_MYMUSIC 0x000D
char *str = SvPV(sv, len);
UINT cp = SvUTF8(sv) ? CP_UTF8 : CP_ACP;
- wlen = MultiByteToWideChar(cp, 0, str, len+1, NULL, 0);
+ wlen = MultiByteToWideChar(cp, 0, str, (int)(len+1), NULL, 0);
New(0, wstr, wlen, WCHAR);
- MultiByteToWideChar(cp, 0, str, len+1, wstr, wlen);
+ MultiByteToWideChar(cp, 0, str, (int)(len+1), wstr, wlen);
return wstr;
}
SV *
wstr_to_sv(pTHX_ WCHAR *wstr)
{
- size_t wlen = wcslen(wstr)+1;
+ int wlen = (int)wcslen(wstr)+1;
BOOL use_default = FALSE;
int len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wstr, wlen, NULL, 0, NULL, NULL);
SV *sv = sv_2mortal(newSV(len));
{
char *name;
BOOL use_default = FALSE;
- size_t widelen = wcslen(widename)+1;
+ int widelen = (int)wcslen(widename)+1;
int len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, widename, widelen,
NULL, 0, NULL, NULL);
New(0, name, len, char);
}
message = SvPV_nolen(ST(1));
- bRet = InitiateSystemShutdownA(machineName, message,
- SvIV(ST(2)), SvIV(ST(3)), SvIV(ST(4)));
+ bRet = InitiateSystemShutdownA(machineName, message, (DWORD)SvIV(ST(2)),
+ (BOOL)SvIV(ST(3)), (BOOL)SvIV(ST(4)));
/* Disable shutdown privilege. */
tkp.Privileges[0].Attributes = 0;
croak("usage: Win32::MsgBox($message [, $flags [, $title]]);\n");
if (items > 1)
- flags = SvIV(ST(1));
+ flags = (DWORD)SvIV(ST(1));
if (IsWin2000()) {
WCHAR *title = NULL;
if (items != 1)
croak("usage: Win32::LoadLibrary($libname)\n");
hHandle = LoadLibraryA(SvPV_nolen(ST(0)));
- XSRETURN_IV((long)hHandle);
+#ifdef _WIN64
+ XSRETURN_IV((DWORD_PTR)hHandle);
+#else
+ XSRETURN_IV((DWORD)hHandle);
+#endif
}
XS(w32_FreeLibrary)
if (SUCCEEDED(hr)) {
LPOLESTR pStr = NULL;
if (SUCCEEDED(StringFromCLSID(&guid, &pStr))) {
- WideCharToMultiByte(CP_ACP, 0, pStr, wcslen(pStr), szGUID,
+ WideCharToMultiByte(CP_ACP, 0, pStr, (int)wcslen(pStr), szGUID,
sizeof(szGUID), NULL, NULL);
CoTaskMemFree(pStr);
XSRETURN_PV(szGUID);
if (items != 1 && items != 2)
croak("usage: Win32::GetFolderPath($csidl [, $create])\n");
- folder = SvIV(ST(0));
+ folder = (int)SvIV(ST(0));
if (items == 2)
create = SvTRUE(ST(1)) ? CSIDL_FLAG_CREATE : 0;
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "usage: Win32::SetLastError($error)");
- SetLastError(SvIV(ST(0)));
+ SetLastError((DWORD)SvIV(ST(0)));
XSRETURN_EMPTY;
}
DWORD wki100_ver_major;
DWORD wki100_ver_minor;
} *pwi;
+ DWORD retval;
+ retval = pfnNetWkstaGetInfo(NULL, 100, &pwi);
/* NERR_Success *is* 0*/
- if (0 == pfnNetWkstaGetInfo(NULL, 100, &pwi)) {
+ if (retval == 0) {
if (pwi->wki100_langroup && *(pwi->wki100_langroup)) {
WideCharToMultiByte(CP_ACP, 0, pwi->wki100_langroup,
-1, (LPSTR)dname, dnamelen, NULL, NULL);
XSRETURN_PV(dname);
}
FreeLibrary(module);
+ SetLastError(retval);
}
else {
/* Win95 doesn't have NetWksta*(), so do it the old way */
if (GIMME_V == G_SCALAR) {
XSRETURN_IV(g_osver.dwPlatformId);
}
- XPUSHs(newSVpvn(g_osver.szCSDVersion, strlen(g_osver.szCSDVersion)));
+ XPUSHs(sv_2mortal(newSVpvn(g_osver.szCSDVersion, strlen(g_osver.szCSDVersion))));
- XPUSHs(newSViv(g_osver.dwMajorVersion));
- XPUSHs(newSViv(g_osver.dwMinorVersion));
- XPUSHs(newSViv(g_osver.dwBuildNumber));
- XPUSHs(newSViv(g_osver.dwPlatformId));
+ XPUSHs(sv_2mortal(newSViv(g_osver.dwMajorVersion)));
+ XPUSHs(sv_2mortal(newSViv(g_osver.dwMinorVersion)));
+ XPUSHs(sv_2mortal(newSViv(g_osver.dwBuildNumber)));
+ XPUSHs(sv_2mortal(newSViv(g_osver.dwPlatformId)));
if (g_osver_ex) {
- XPUSHs(newSViv(g_osver.wServicePackMajor));
- XPUSHs(newSViv(g_osver.wServicePackMinor));
- XPUSHs(newSViv(g_osver.wSuiteMask));
- XPUSHs(newSViv(g_osver.wProductType));
+ XPUSHs(sv_2mortal(newSViv(g_osver.wServicePackMajor)));
+ XPUSHs(sv_2mortal(newSViv(g_osver.wServicePackMinor)));
+ XPUSHs(sv_2mortal(newSViv(g_osver.wSuiteMask)));
+ XPUSHs(sv_2mortal(newSViv(g_osver.wProductType)));
}
PUTBACK;
}
Perl_croak(aTHX_ "usage: Win32::FormatMessage($errno)");
if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM,
- &source, SvIV(ST(0)), 0,
+ &source, (DWORD)SvIV(ST(0)), 0,
msgbuf, sizeof(msgbuf)-1, NULL))
{
XSRETURN_PV(msgbuf);
do {
len = GetShortPathName(SvPVX(shortpath),
SvPVX(shortpath),
- SvLEN(shortpath));
+ (DWORD)SvLEN(shortpath));
} while (len >= SvLEN(shortpath) && sv_grow(shortpath,len+1));
if (len) {
SvCUR_set(shortpath,len);
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "usage: Win32::Sleep($milliseconds)");
- Sleep(SvIV(ST(0)));
+ Sleep((DWORD)SvIV(ST(0)));
XSRETURN_YES;
}
XSRETURN_EMPTY;
}
+XS(w32_GetCurrentProcessId)
+{
+ dXSARGS;
+ EXTEND(SP,1);
+ XSRETURN_IV(GetCurrentProcessId());
+}
+
XS(w32_GetCurrentThreadId)
{
dXSARGS;
newXS("Win32::CopyFile", w32_CopyFile, file);
newXS("Win32::Sleep", w32_Sleep, file);
newXS("Win32::OutputDebugString", w32_OutputDebugString, file);
+ newXS("Win32::GetCurrentProcessId", w32_GetCurrentProcessId, file);
newXS("Win32::GetCurrentThreadId", w32_GetCurrentThreadId, file);
newXS("Win32::CreateDirectory", w32_CreateDirectory, file);
newXS("Win32::CreateFile", w32_CreateFile, file);