获取当前正在WriteFile中编写的文件名

时间:2017-07-26 08:01:41

标签: c++ winapi

BOOL WINAPI MyWriteFile(
 _In_        HANDLE       hFile,
 _In_        LPCVOID      lpBuffer,
 _In_        DWORD        nNumberOfBytesToWrite,
 _Out_opt_   LPDWORD      lpNumberOfBytesWritten,
 _Inout_opt_ LPOVERLAPPED lpOverlapped
)
{
LPTSTR filepath;
DWORD  filepathlength=500;    
GetFinalPathNameByHandle(hFile,filepath,filepathlength,FILE_NAME_NORMALIZED);
return WriteFile(hFile,lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,lpOverlaped)
}

这个函数是用dll编写的,它实现了软件的安全性,注入了这个软件我希望得到当前正在编写的文件名。我尝试使用GetFinalPathNameByHandle(),但在Visual Studio 2013中,它表示GetFinalPathNameByHandle未定义。在这方面的任何帮助将不胜感激。

被修改

错误列表

错误2

错误C3861:' GetFinalPathNameByHandle':未找到标识符test.cpp 132 test.cpp

IntelliSense:标识符" GetFinalPathNameByHandle"是未定义的test.cpp 132 test.cpp

编辑2

i included #include <FileAPI.h> 

#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <algorithm>
#include <iterator>
#include <assert.h>
#include <FileAPI.h>

但我仍然遇到同样的错误。

编辑3

通过从stdafx.h中删除这些行来解决问题

#ifndef _WIN32_WINNT        // Allow use of features specific to Windows XP 
or 
later.                   
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to 
target other versions of Windows.
#endif      

谢谢大家

0 个答案:

没有答案
相关问题