Last active
April 20, 2019 06:00
-
-
Save ubuntor/9fa7be4c51afb889a6871a9fbb8f6bf6 to your computer and use it in GitHub Desktop.
Test case for ValveSoftware/Proton #2452
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UNICODE | |
#define UNICODE | |
#endif | |
const wchar_t CLASS_NAME[] = L"class"; | |
#include <cstdio> | |
#include <windows.h> | |
#include <io.h> | |
#include <fcntl.h> | |
#include <shlobj.h> | |
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, | |
LPARAM lParam) { | |
switch (uMsg) { | |
case WM_DESTROY: | |
PostQuitMessage(0); | |
return 0; | |
default: | |
return DefWindowProc(hwnd, uMsg, wParam, lParam); | |
} | |
} | |
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, | |
int nCmdShow) { | |
WNDCLASS wc = {}; | |
wc.lpfnWndProc = WindowProc; | |
wc.hInstance = hInstance; | |
wc.lpszClassName = CLASS_NAME; | |
RegisterClass(&wc); | |
HWND hwnd = CreateWindowEx(0, CLASS_NAME, L"title", WS_OVERLAPPEDWINDOW, | |
CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, | |
NULL, NULL, hInstance, NULL); | |
if (hwnd == NULL) { | |
return 0; | |
} | |
ShowWindow(hwnd, nCmdShow); | |
AllocConsole(); | |
SetConsoleTitle(L"Debug Output"); | |
HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); | |
DWORD written = 0; | |
char buffer[256]; | |
// test begin | |
const wchar_t path[] = L"C:\\Windows\\Temp\\test"; | |
// make sure directory exists | |
SHCreateDirectory(NULL, path); | |
int res; | |
res = SHCreateDirectory(NULL, path); | |
sprintf_s(buffer, 256, "SHCreateDirectory, NULL hwnd: %d\n", res); | |
WriteConsoleA(consoleHandle, buffer, strlen(buffer), &written, NULL); | |
res = SHCreateDirectory(hwnd, path); | |
sprintf_s(buffer, 256, "SHCreateDirectory, actual hwnd: %d\n", res); | |
WriteConsoleA(consoleHandle, buffer, strlen(buffer), &written, NULL); | |
res = SHCreateDirectoryExW(NULL, path, NULL); | |
sprintf_s(buffer, 256, "SHCreateDirectoryExW, NULL hwnd: %d\n", res); | |
WriteConsoleA(consoleHandle, buffer, strlen(buffer), &written, NULL); | |
res = SHCreateDirectoryExW(hwnd, path, NULL); | |
sprintf_s(buffer, 256, "SHCreateDirectoryExW, actual hwnd: %d\n", res); | |
WriteConsoleA(consoleHandle, buffer, strlen(buffer), &written, NULL); | |
// test end | |
MSG msg = {}; | |
while (GetMessage(&msg, NULL, 0, 0)) { | |
TranslateMessage(&msg); | |
DispatchMessage(&msg); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment