2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for GetModuleFileName
5 * PROGRAMMER: Thomas Faber <thfabba@gmx.de>
8 #define WIN32_NO_STATUS
10 #define COM_NO_WINDOWS_H
13 #include <wine/test.h>
20 StartChild(char **argv
)
26 WCHAR CommandLine
[MAX_PATH
];
27 STARTUPINFO StartupInfo
;
28 PROCESS_INFORMATION ProcessInfo
;
32 Length
= MultiByteToWideChar(CP_ACP
,
37 sizeof(Path
) / sizeof(WCHAR
));
39 FileName
= wcsrchr(Path
, '\\');
40 Slash
= wcsrchr(Path
, L
'/');
41 if (Slash
&& (!FileName
|| Slash
> FileName
))
46 /* It's an absolute path. Set it as current dir and get the file name */
50 Success
= SetCurrentDirectory(Path
);
51 ok(Success
== TRUE
, "SetCurrentDirectory failed for path '%ls'\n", Path
);
53 trace("Starting '%ls' in path '%ls'\n", FileName
, Path
);
58 trace("Starting '%ls', which is already relative\n", FileName
);
61 swprintf(CommandLine
, L
"\"%ls\" GetModuleFileName relative", FileName
);
63 RtlZeroMemory(&StartupInfo
, sizeof(StartupInfo
));
64 StartupInfo
.cb
= sizeof(StartupInfo
);
66 Success
= CreateProcess(FileName
,
78 skip("CreateProcess failed with %lu\n", GetLastError());
81 CloseHandle(ProcessInfo
.hThread
);
82 Ret
= WaitForSingleObject(ProcessInfo
.hProcess
, 30 * 1000);
83 ok(Ret
== WAIT_OBJECT_0
, "WaitForSingleObject returns %lu\n", Ret
);
84 CloseHandle(ProcessInfo
.hProcess
);
89 TestGetModuleFileNameA(VOID
)
91 CHAR Buffer
[MAX_PATH
];
95 Length
= GetModuleFileNameA(NULL
, Buffer
, sizeof(Buffer
));
96 ok(Length
!= 0, "Length = %lu\n", Length
);
97 ok(Length
< sizeof(Buffer
), "Length = %lu\n", Length
);
98 ok(Buffer
[Length
] == 0, "Buffer not null terminated\n");
99 Relative
= PathIsRelativeA(Buffer
);
100 ok(Relative
== FALSE
, "GetModuleFileNameA returned relative path: %s\n", Buffer
);
105 TestGetModuleFileNameW(VOID
)
107 WCHAR Buffer
[MAX_PATH
];
111 Length
= GetModuleFileNameW(NULL
, Buffer
, sizeof(Buffer
) / sizeof(WCHAR
));
112 ok(Length
!= 0, "Length = %lu\n", Length
);
113 ok(Length
< sizeof(Buffer
) / sizeof(WCHAR
), "Length = %lu\n", Length
);
114 ok(Buffer
[Length
] == 0, "Buffer not null terminated\n");
115 Relative
= PathIsRelativeW(Buffer
);
116 ok(Relative
== FALSE
, "GetModuleFileNameA returned relative path: %ls\n", Buffer
);
119 START_TEST(GetModuleFileName
)
124 argc
= winetest_get_mainargs(&argv
);
129 TestGetModuleFileNameA();
130 TestGetModuleFileNameW();