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

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.030
BTC 58269.26
ETH 3067.65
USDT 1.00
SBD 2.25