1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*============================================================= |
6 | ** |
7 | ** Source: getmodulefilenamew.c |
8 | ** |
9 | ** Purpose: Positive test the GetModuleFileName API. |
10 | ** Call GetModuleFileName to retrieve current process |
11 | ** full path and file name by passing a NULL module handle |
12 | ** in UNICODE |
13 | ** |
14 | ** |
15 | **============================================================*/ |
16 | #define UNICODE |
17 | #include <palsuite.h> |
18 | |
19 | #define MODULENAMEBUFFERSIZE 1024 |
20 | |
21 | |
22 | int __cdecl main(int argc, char *argv[]) |
23 | { |
24 | |
25 | DWORD ModuleNameLength; |
26 | WCHAR *ModuleFileNameBuf; |
27 | int err; |
28 | |
29 | |
30 | //Initialize the PAL environment |
31 | err = PAL_Initialize(argc, argv); |
32 | if(0 != err) |
33 | { |
34 | ExitProcess(FAIL); |
35 | } |
36 | |
37 | ModuleFileNameBuf = (WCHAR*)malloc(MODULENAMEBUFFERSIZE*sizeof(WCHAR)); |
38 | |
39 | //retrieve the current process full path and file name |
40 | //by passing a NULL module handle |
41 | ModuleNameLength = GetModuleFileName( |
42 | NULL, //a NULL handle |
43 | ModuleFileNameBuf,//buffer for module file name |
44 | MODULENAMEBUFFERSIZE); |
45 | |
46 | //free the memory |
47 | free(ModuleFileNameBuf); |
48 | |
49 | if(0 == ModuleNameLength) |
50 | { |
51 | Fail("\nFailed to all GetModuleFileName API!\n" ); |
52 | } |
53 | |
54 | |
55 | PAL_Terminate(); |
56 | return PASS; |
57 | } |
58 | |