在VS 2013中,我在编译/链接NetmonAPI时遇到了问题。API随安装而来。Networkmonitor甚至在“帮助”中解释了如何让它在VS中工作。我按照说明如何设置它,尝试了一个帮助的例子,但失败了。我总是得到七个符号的"LNK2019"错误。
我使用的示例代码:
#include "Stdafx.h"
#include "windows.h"
#include "stdio.h"
#include "stdlib.h"
#include "objbase.h"
#include "ntddndis.h"
#include "NMApi.h"
void __stdcall
MyFrameIndication(HANDLE hCapEng, ULONG ulAdaptIdx, PVOID pContext, HANDLE hRawFrame)
{
HANDLE capFile = (HANDLE)pContext;
NmAddFrame(capFile, hRawFrame);
}
int __cdecl wmain(int argc, WCHAR* argv[])
{
ULONG ret;
ULONG adapterIndex = 0;
if(2 == argc)
adapterIndex = _wtol(argv[1]);
// Open a capture file for saving frames.
HANDLE myCapFile;
ULONG CapSize;
ret = NmCreateCaptureFile(L"20sec.cap", 20000000, NmCaptureFileWrapAround, &myCapFile, &CapSize);
if(ret != ERROR_SUCCESS)
{
wprintf(L"Error opening capture file, 0x%X\n", ret);
return ret;
}
// Open the capture engine.
HANDLE myCaptureEngine;
ret = NmOpenCaptureEngine(&myCaptureEngine);
if(ret != ERROR_SUCCESS)
{
wprintf(L"Error opening capture engine, 0x%X\n", ret);
NmCloseHandle(myCapFile);
return ret;
}
//Configure the adapter.
ret = NmConfigAdapter(myCaptureEngine, adapterIndex, MyFrameIndication, myCapFile);
if(ret != ERROR_SUCCESS)
{
wprintf(L"Error configuration adapter, 0x%X\n", ret);
NmCloseHandle(myCaptureEngine);
NmCloseHandle(myCapFile);
return ret;
}
//Start capturing frames.
wprintf(L"Capturing for 20 seconds\n");
NmStartCapture(myCaptureEngine, adapterIndex, NmLocalOnly);
Sleep(20000);
wprintf(L"Stopping capture\n");
NmStopCapture(myCaptureEngine, adapterIndex);
NmCloseHandle(myCaptureEngine);
NmCloseHandle(myCapFile);
return 0;
}我发现的一个错误是:
在这里,我的脚步:
我不知道我是否有一个可弥补的问题,因为说明是针对VS 2005和2008年。
提前感谢!
发布于 2017-05-28 15:29:50
我认为这是32/64位的问题。
在我的例子中,我有一个带有windows 7 64位操作系统的桌面机器。
我有一个使用windows 7工具链的eclipse。
我对你犯了同样的错误,但环境不同。

我还安装了64位3.4。

正如你所看到的,它是64位的。
嗯,我已经成功地用'/machine:x64‘作为链接器选项编译了我的测试程序。
这个问题可能是没有32位支持的64位监视器库。
所以,我想你还需要和我一样的链接器选项。
下面是我使用windows 7编写的编译日志。



请参阅microsoft 这里。
回答太迟了,也许..。
https://stackoverflow.com/questions/35703128
复制相似问题