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