This kind of driver mainly presents streaming function interfaces, including XXX_Init, XXX_Deinit, XXX_Open, XXX_Close, XXX_Read, XXX_Write, XXX_Seek, XXX_IOControl, XXX_PowerUp, XXX_PowerDown, etc, note that the preceding interfaces must be output, and XXX must contain three characters. Otherwise, an error occurs. You can manually call the RegisterDevice () and DeregisterDevice () functions to load and uninstall the driver. Users can operate such devices as standard files. They can interact with the driver by calling corresponding file operations.
1. Compile the driver source file under EVC to generate the driver DLL.
Note: during compilation, pay attention to project setting. To add the driver's export file, add/def: "bsp_ir.def" to project options. This step is very important, otherwise, the driver cannot be called by the application. You can also use _ declspec (dllexport) to save the need to manually define which functions to export in the DEF file.
2. Use EVC to write a program that dynamically loads the driver, for example:
// Dynamically load the stream driver;
HANDLE m_hIR;
M_hIR = RegisterDevice (TEXT ("IRD"), 1, TEXT ("bsp_ir.dll"), 1); // the file name of your stream driver
If (m_hIR = NULL ){
: MessageBox (NULL, NULL, _ T ("load driver fail! "), MB_ OK );
}
Else
: MessageBox (NULL, NULL, _ T ("load driver sucess"), MB_ OK );
// Uninstall the stream driver;
: MessageBox (NULL, NULL, _ T ("unload driver"), MB_ OK );
DeregisterDevice (m_hIR );
3. Copy the generated DLL file to the windows directory of the Target Platform and use the application to dynamically load the driver.
I have not added the driver registration information in the registry or can access it using an application. It may not be necessary.
This article from the CSDN blog, reproduced please indicate the source: http://blog.csdn.net/wincemobile/archive/2009/05/06/4154981.aspx