那位大侠能告诉我
我想调用某一文件夹下的可执行文件 该怎么写呢?
我先谢谢了.
我想调用某一文件夹下的可执行文件 该怎么写呢?
我先谢谢了.
解决方案 »
- CDC怎样画掉残影?
- 在游戏开发中,游戏精灵的设计是不是会有专业的美工人员来设计,程序员只负责编码??
- VC调试很不方便,大虾们出出招阿?
- 如何用LogonUser登录局域网中的其它机器(用户名,密码已知)?
- c语言中用什么函数更改已经存在文件属性!
- How to add a Dialog before the main window start?
- 问一个很笨的问题?
- 关于CIFS?(100)
- 如何确定局域网上的驱动器类型(Harddisk CDROM Floppy) When I use GetDriveType("\\\\name\\C:"),It's not work
- 2002年第一期的程序员什么时候出版啊? 一般是每个月的什么时候?
- 十万元聘请网站高级编程高手
- 傻傻的说:VC中这个文件是干吗使得?
也可以用CreateProcess()
LPCTSTR lpApplicationName,
LPTSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCTSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
);
32位的应用程序应该使用CreateProcess
#include <pcap.h>
#include <wtypes.h>// Struct of ethernet II header
typedef struct
{
UCHAR DestMac[6];
UCHAR SrcMac[6];
UCHAR Etype[2];
}ETHHEADER, *PETHHEADER;#define ETHHEADERSIZE 14HANDLE hStdOut;// dispatcher routine prototype
void dispatcher_handler(u_char*, const pcap_pkthdr*, const u_char*);void main(void)
{
char ebuf[PCAP_ERRBUF_SIZE]; // error buffer
char *adapter; // adapter name
pcap_t* fp; // packet capture descriptor hStdOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
// Step 1: Lookup the adapter
adapter=(char*)pcap_lookupdev(ebuf);
if(adapter == NULL)
{
printf(TEXT("PCAP error:%s\n"), ebuf);
return;
} // Step 2: Open the adapter
// Note: the adapter may not proper adapter!!
fp = pcap_open_live(adapter, 2000, 1, 20, ebuf);
if(fp == NULL)
{
printf(TEXT("PCAP error:%s\n"), ebuf);
return;
} // Step 3: Check the datalink.
if(pcap_datalink(fp) != DLT_EN10MB)
{
printf("Not Ethernet 10MB adapter!\n");
pcap_close(fp);
return;
} // Step 4: Start capturing.
pcap_loop(fp, 0, dispatcher_handler, NULL); // Step 5: Close the adapter.
pcap_close(fp);
}#define ATTR_NORMAL (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
#define ATTR_VALUE (FOREGROUND_GREEN)
#define ATTR_DATA (FOREGROUND_RED | FOREGROUND_BLUE)// callback routine called by libpcap for every incoming packet
void dispatcher_handler(u_char *,const struct pcap_pkthdr *header, const u_char *pkt_data)
{
PETHHEADER eth_header = (PETHHEADER)pkt_data;
::SetConsoleTextAttribute(hStdOut, ATTR_NORMAL);
printf("\r\nCaptured time:");
::SetConsoleTextAttribute(hStdOut, ATTR_VALUE);
printf("%ld:%ld",header->ts.tv_sec, header->ts.tv_usec);
::SetConsoleTextAttribute(hStdOut, ATTR_NORMAL);
printf("\r\nPacket Length:");
::SetConsoleTextAttribute(hStdOut, ATTR_VALUE);
printf("%ld",header->len); if (header->len >= ETHHEADERSIZE)
{
::SetConsoleTextAttribute(hStdOut, ATTR_NORMAL);
printf("\r\nDestination MAC:");
::SetConsoleTextAttribute(hStdOut, ATTR_VALUE);
printf("%02X-%02X-%02X-%02X-%02X-%02X", eth_header->DestMac[0],
eth_header->DestMac[1], eth_header->DestMac[2], eth_header->DestMac[3],
eth_header->DestMac[4], eth_header->DestMac[5]); ::SetConsoleTextAttribute(hStdOut, ATTR_NORMAL);
printf("\r\nSource MAC:");
::SetConsoleTextAttribute(hStdOut, ATTR_VALUE);
printf("%02X-%02X-%02X-%02X-%02X-%02X", eth_header->SrcMac[0],
eth_header->SrcMac[1], eth_header->SrcMac[2], eth_header->SrcMac[3],
eth_header->SrcMac[4], eth_header->SrcMac[5]); ::SetConsoleTextAttribute(hStdOut, ATTR_NORMAL);
printf("\r\nProtocol type:");
::SetConsoleTextAttribute(hStdOut, ATTR_VALUE);
printf("%02X%02X", eth_header->Etype[0], eth_header->Etype[1]);
}
::SetConsoleTextAttribute(hStdOut, ATTR_DATA);
printf("\r\n");
u_char *p = (u_char *)pkt_data;
for(int i = 0; i < (int)header->len; i++)
{
printf("%02X ", *p++);
if( (i + 1) % 16 == 0)
printf("\n");
}
}
是 Win32 Console Application 生成可执行文件
以为是调用了WinpCap库来捕获数据包
要在系统中加载wpcap.lib文件就行了
我已经调试通过了
库文件可在
http://winpcap.polito.it上下载
files ,Library files 路径加入
就可以了
运行后是捕获以太网数据帧的程序
我想将其假如到我的另一个程序中
用WinExec 还是CreateProcess()
这两个函数的参数又是怎么写的?
没报错
但是没法运行
如果WinExec成功执行,他的返回值大于31
我的信箱是 [email protected]