Using litteral L"Unicode string", and WCHAR (wchar_t)
UNICODE is a mandatory in modern Windows programming.
So far I am forced to use
Dim zSkinFile As WString * 260 => "Sony.sks"
and pass the string pointer like this: @zSkinFile
Also does there is a built-in function to retrieve the EXE path of an executable.
So far I am using this, but that doesn't work
Code: Select all
Function EXEpath() As WString Ptr
Static usepath As WString * MAX_PATH
Dim As DWORD result = GetModuleFileNameW(0, usepath, MAX_PATH)
If result > 0 Then
Dim As Long nLen = wcslen(usepath)
For k As Long = 1 To nLen
If wcsicmp(@usepath[nLen - k], @"\") <> 0 Then
usepath[nLen - k] = 0
Else
Exit For
End If
Next
End If
Return @usepath
End Function
Here is my original C/C++ function
Code: Select all
static void ClearMemory(IN void* mem, IN long nSize) {
#ifdef _WIN64
__stosb((PBYTE) mem, (BYTE) 0, (SIZE_T) nSize);
#elif defined(_WIN32)
memset(mem, 0, nSize);
#endif
}
Code: Select all
#define strSize(s) ( sizeof(s) / sizeof(s[0]) )
static WCHAR* EXEpath() {
static WCHAR zpath[MAX_PATH];
static long done;
if (done == 0) {
ClearMemory(zpath, sizeof(zpath));
if (GetModuleFileName(0, zpath, strSize(zpath))) {
long nLen = lstrlen(zpath);
long nPos = nLen;
for (long K = 1; K <= nLen; K++) {
if (_wcsicmp(&zpath[nPos - K], L"\\") != 0) {
zpath[nPos - K] = NULL;
} else {
break;
}
}
}
done = -1;
}
return zpath;
}