阅读:1174回复:1
中断形式的采集卡的vxd与win32通信问题
编了一个数据采集卡的中断程序,生成的vxd在win32下调试无问题,但就是无法正常通信(采集的数据很乱),请各大虾指教,win32部分源程序如下:
#include <stdio.h> #include <conio.h> #include <windows.h> #include <winioctl.h> #include \"apcx.h\" HANDLE hDevice; //PVOID RetInf=0; int i; DWORD WINAPI SecondThread(PVOID hEventRing3) { while(TRUE) { WaitForSingleObject(hEventRing3,INFINITE); DeviceIoControl(hDevice,READ,0,0,&i,0,0,0); printf(\"%d\\n\", i); } return 0; } void main() { // PDWORD pVal=(PDWORD)0x9fffc; unsigned short* BufferAddr; HANDLE hEventRing3,hEventToNotifyApp; HMODULE hKernel32Dll; DWORD tid; HANDLE (WINAPI *pfOpenVxDHandle)(HANDLE); hEventRing3=CreateEvent(0,FALSE,FALSE,NULL); if (!hEventRing3) { fprintf(stderr,\"Failed to create event3...\\n\"); exit(1); } hKernel32Dll=LoadLibrary(\"kernel32.dll\"); if (!hKernel32Dll) { fprintf(stderr, \"Failed to load...\\n\"); exit(1); } pfOpenVxDHandle=(HANDLE(WINAPI *)(HANDLE))GetProcAddress(hKernel32Dll,\"OpenVxDHandle\"); if (!pfOpenVxDHandle) { fprintf(stderr, \"Failed to get...\\n\"); exit(1); } hEventToNotifyApp=(HANDLE)(*pfOpenVxDHandle)(hEventRing3); if (!hEventToNotifyApp) { fprintf(stderr, \"Failed to get hEventToNotifyApp...\\n\"); exit(1); } hDevice=CreateFile(\"\\\\\\\\.\\\\CLOCK.VXD\",0,0,0,CREATE_NEW,FILE_FLAG_DELETE_ON_CLOSE,0); if (hDevice == INVALID_HANDLE_VALUE) { fprintf(stderr,\"Cannot load VxD,error=%08ld\\n\",GetLastError()); exit(1); } if ( !DeviceIoControl(hDevice,W32IF_PASS_FINE,hEventToNotifyApp,sizeof(hEventToNotifyApp),&BufferAddr,sizeof(BufferAddr),0,NULL)) { fprintf(stderr, \"Failed to pass hEvent...\\n\"); exit(1); } for(i=0;i<300;i=i++) { printf(\" %d \", BufferAddr); } CreateThread(0,0x1000,SecondThread,hEventRing3,0,&tid); printf(\"press any key to exit . . .\\n\"); getch(); CloseHandle(hDevice); } |
|
沙发#
发布于:2002-04-02 20:57
快点复吧,急
|
|