Книга: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

Implementing Stream Functions

Implementing Stream Functions

Having created the DLL subproject, you can open the source code file in Visual Studio and add the required functions to implement the stream interface and required driver functionality. The following code listing shows the definition of the stream interface functions.

// SampleDriver.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
BOOL APIENTRY DllMain(HANDLE hModule,
 DWORD ul_reason_for_call, LPVOID lpReserved) {
 return TRUE;
}
DWORD SMP_Init(LPCTSTR pContext, LPCVOID lpvBusContext) {
 // Implement device context initialization code here.
 return 0x1;
}
BOOL SMP_Deinit(DWORD hDeviceContext) {
 // Implement code to close the device context here.
 return TRUE;
}
DWORD SMP_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode) {
 // Implement open context initialization code here.
 return 0x2;
}
BOOL SMP_Close(DWORD hOpenContext) {
 // Implement code to close the open context here.
 return TRUE;
}
DWORD SMP_Write(DWORD hOpenContext, LPCVOID pBuffer, DWORD Count) {
 // Implement the code to write to the stream device here.
 return Count;
}
DWORD SMP_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count) {
 // Implement the code to read from the stream device here.
 return Count;
}
BOOL SMP_IOControl(DWORD hOpenContext, DWORD dwCode,
 PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut,
 DWORD dwLenOut, PDWORD pdwActualOut) {
 // Implement code to handle advanced driver actions here.
 return TRUE;
}
void SMP_PowerUp(DWORD hDeviceContext) {
 // Implement power management code here or use IO Control.
 return;
}
void SMP_PowerDown(DWORD hDeviceContext) {
 // Implement power management code here or use IO Control.
 return;
}

Оглавление книги

Оглавление статьи/книги

Генерация: 1.088. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз