| 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: getmodulefilenamea.c |
| 8 | ** |
| 9 | ** Purpose: Positive test the GetModuleFileNameA API. |
| 10 | ** Call GetModuleFileName to retrieve current process |
| 11 | ** full path and file name by passing a NULL module handle |
| 12 | ** |
| 13 | ** |
| 14 | **============================================================*/ |
| 15 | #include <palsuite.h> |
| 16 | |
| 17 | |
| 18 | #define MODULENAMEBUFFERSIZE 1024 |
| 19 | |
| 20 | int __cdecl main(int argc, char *argv[]) |
| 21 | { |
| 22 | |
| 23 | DWORD ModuleNameLength; |
| 24 | char ModuleFileNameBuf[MODULENAMEBUFFERSIZE]="" ; |
| 25 | int err; |
| 26 | |
| 27 | //Initialize the PAL environment |
| 28 | err = PAL_Initialize(argc, argv); |
| 29 | if(0 != err) |
| 30 | { |
| 31 | ExitProcess(FAIL); |
| 32 | } |
| 33 | |
| 34 | |
| 35 | //retrieve the current process full path and file name |
| 36 | //by passing a NULL module handle |
| 37 | ModuleNameLength = GetModuleFileName( |
| 38 | NULL, //a NULL handle |
| 39 | ModuleFileNameBuf,//buffer for module file name |
| 40 | MODULENAMEBUFFERSIZE); |
| 41 | |
| 42 | if(0 == ModuleNameLength) |
| 43 | { |
| 44 | Fail("\nFailed to all GetModuleFileName API!\n" ); |
| 45 | } |
| 46 | |
| 47 | PAL_Terminate(); |
| 48 | return PASS; |
| 49 | } |
| 50 | |