Hi.
I want to delete a file that is under use but I don't know how... so Maybe you could help me. If I use Delete ( "path\\filename" ); I can delete normal files but this doesn't delete files that are being used.
So I searched for it and I found this code but I don't understand it so I hoped you could help me. I really don't know how to use this code but I really want.
I use Dev-C++ compiler and I have included windows.h.
Here is the code:
If I try to use this code I get like 100 errors, here are some view:Code:bool newDeleteFile(LPCSTR lpFileName) { OBJECT_ATTRIBUTES pObj; UNICODE_STRING uFile; WCHAR wFile[256]; // create an UNICODE path swprintf(wFile, L"\\??\\%S", lpFileName); // create UNICODE_STRING pRtlInitUnicodeString(&uFile, wFile); // setup OBJECT_ATTRIBUTES for NtDeleteFile InitializeObjectAttributes(&pObj, &uFile, OBJ_CASE_INSENSITIVE, NULL, NULL); if(NT_SUCCESS(pNtDeleteFile(&pObj))) return true; return false; }
Thanks.Code:`OBJECT_ATTRIBUTES' undeclared (first use this function) expected `;' before "pObj" `UNICODE_STRING' undeclared (first use this function) expected `;' before "uFile" `uFile' undeclared (first use this function) `pRtlInitUnicodeString' undeclared (first use this function) `pObj' undeclared (first use this function) `OBJ_CASE_INSENSITIVE' undeclared (first use this function) `InitializeObjectAttributes' undeclared (first use this function) `pNtDeleteFile' undeclared (first use this function) `NT_SUCCESS' undeclared (first use this function)



LinkBack URL
About LinkBacks



. I don't see what is wrong, here is the code I use: (I use Dev-C++ so I don't use #pragma but I link it in Project options, under tab Parameters: Compiler: -advapi32 C++ Compiler: Linker: -advapi32. )
, (not for the the game because I need to use EnumProcess() and that function doesn't work with Dev-C++ compilers,