Get Full Path / Get File Name from Path with Native ApisteemCreated with Sketch.

in Computer Programming3 years ago (edited)

fullPath.png

#pragma comment(lib, "ntdll.lib")
#include <Windows.h>

ULONG NTAPI RtlGetFullPathName_U(PCWSTR FileName,ULONG Size,PWSTR Buffer,PWSTR *ShortName);

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
    wchar_t fullPath1[MAX_PATH], fullPath2[MAX_PATH];
    PWSTR shorName1, shorName2;

    //Method 1
    RtlGetFullPathName_U(L"..\\file.txt", MAX_PATH, fullPath1, &shorName1);

    //Method 2
    GetFullPathNameW(L"..\\file.txt", MAX_PATH, fullPath2, &shorName2);

    return 0;
}

Please Vote this post if you like it.
Please Follow me if you like my posts.
If you have any questions about this post, ask in comments.
Follow me on :
DTube
Hive