Created
August 25, 2017 01:16
-
-
Save Clarence-pan/ac6194316a42f16399439cc169fb0a19 to your computer and use it in GitHub Desktop.
Test GetFullPathName
This file contains 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
#include "windows.h" | |
#include <tchar.h> | |
#include <stdio.h> | |
#define BUFSIZE 4096 | |
void _tmain(int argc, TCHAR *argv[]) | |
{ | |
DWORD retval=0; | |
BOOL success; | |
TCHAR buffer[BUFSIZE]=TEXT(""); | |
TCHAR buf[BUFSIZE]=TEXT(""); | |
TCHAR** lppPart={NULL}; | |
if( argc != 2 ) | |
{ | |
_tprintf(TEXT("Usage: %s [file]\n"), argv[0]); | |
return; | |
} | |
// Retrieve the full path name for a file. | |
// The file does not need to exist. | |
retval = GetFullPathName(argv[1], | |
BUFSIZE, | |
buffer, | |
lppPart); | |
if (retval == 0) | |
{ | |
// Handle an error condition. | |
printf ("GetFullPathName failed (%d)\n", GetLastError()); | |
return; | |
} | |
else | |
{ | |
_tprintf(TEXT("The full path name is: %s\n"), buffer); | |
if (lppPart != NULL && *lppPart != 0) | |
{ | |
_tprintf(TEXT("The final component in the path name is: %s\n"), *lppPart); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment