Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created March 6, 2015 23:31
Show Gist options
  • Save kumatti1/ce81283795d25c0c3eda to your computer and use it in GitHub Desktop.
Save kumatti1/ce81283795d25c0c3eda to your computer and use it in GitHub Desktop.
FindFirstFileTransacted
#define UNICODE
#include <windows.h>
#include <KtmW32.h>
#pragma comment(lib, "KtmW32.lib")
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
{
HANDLE hTran = CreateTransaction( nullptr, 0,TRANSACTION_DO_NOT_PROMOTE, 0,0,INFINITE,L"σ(゚∀゚ )オレ氏" );
if (hTran == INVALID_HANDLE_VALUE)
return -1;
WIN32_FIND_DATA wfd = {};
HANDLE hFile = FindFirstFileTransacted(L"D:*", FindExInfoStandard, &wfd, FindExSearchLimitToDirectories,nullptr,0, hTran );
if(hFile == INVALID_HANDLE_VALUE)
return -1;
BOOL Ret = TRUE;
while(Ret)
{
if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
OutputDebugString( L"Dir" );;
}
else
{
OutputDebugString( L"File" );
}
Ret = FindNextFile(hFile,&wfd);
}
FindClose(hFile);
CommitTransaction(hTran);
CloseHandle(hTran);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment