鉴于网上有人向我要一个简单的流驱动的例子,其实PB自己带例子已经很多了!但是对于初学者可能不知道到哪儿找所以发表一个简单的流驱动模板,对于老鸟可能没有用不过对于初学者或许有用!这个驱动的功能是保存一个字符串!希望对初学者有帮助!
驱动程序部分
#define _WIN32_WINNT 0x0400 #include <windows.h> #include <tchar.h>
HANDLE g_hInstance;
#define BUFSIZE 256 WCHAR achBuffer[BUFSIZE];
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- BOOL WINAPI DllEntryPoint(HANDLE hinstDLL, DWORD dwReason, LPVOID /* lpvReserved */) { switch(dwReason) { case DLL_PROCESS_ATTACH: g_hInstance = hinstDLL; RETAILMSG(1,(TEXT("STRINGS: DLL_PROCESS_ATTACH"))); return TRUE; case DLL_THREAD_ATTACH: RETAILMSG(1,(TEXT("STRINGS: DLL_THREAD_ATTACH\n"))); break; case DLL_THREAD_DETACH: RETAILMSG(1,(TEXT("STRINGS: DLL_THREAD_DETACH\n"))); break; case DLL_PROCESS_DETACH: RETAILMSG(1,(TEXT("STRINGS: DLL_PROCESS_DETACH\n"))); break; #ifdef UNDER_CE case DLL_PROCESS_EXITING: RETAILMSG(1,(TEXT("STRINGS: DLL_PROCESS_EXITING\n"))); break; case DLL_SYSTEM_STARTED: RETAILMSG(1,(TEXT("STRINGS: DLL_SYSTEM_STARTED\n"))); break; #endif }
return TRUE; }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- BOOL STR_Close(DWORD hOpenContext) { BOOL bRet = TRUE; RETAILMSG(1,(TEXT("STRINGS: STR_Close\n"))); return bRet; }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- BOOL STR_Deinit(DWORD hDeviceContext) { BOOL bRet = TRUE; RETAILMSG(1,(TEXT("STRINGS: STR_Deinit\n"))); return bRet; }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- DWORD STR_Init(DWORD dwContext) { DWORD dwRet = 0; RETAILMSG(1,(TEXT("STRINGS: STR_Init\n")));
// Initialize buffer to zero. memset (achBuffer, 0, BUFSIZE * sizeof(WCHAR));
// Set return value to non-zero. dwRet = 1; return dwRet; }
//----------------------------------------------------------------------------- |