请问dll文件
时间:12-13
整理:3721RD
点击:
应该是这样的格式写么?
// myPhaDll.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "myPhaDll.h"
#include "define.h"
#include "winioctl.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// This is an example of an exported variable
MYPHADLL_API int nMyPhaDll=0;
// This is an example of an exported function.
MYPHADLL_API bool fnMyPhaDll(void)
{
return true;
}
// This is the constructor of a class that has been exported.
// see myPhaDll.h for the class definition
CMyPhaDll::CMyPhaDll()
{
return;
}
extern "C"
{
MYPHADLL_API int myAdd(int a, int b)
{
return a*b;
}
MYPHADLL_API bool InitDevice() // = createfile
{
hDev = CreateFile(LINKNAME,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hDev== INVALID_HANDLE_VALUE)
return FALSE;
else
return TRUE;
}
MYPHADLL_API bool StartDevice() // = START_HANDLE
{
if (!DeviceIoControl(hDev, DdDRIVER_IOCTL_START, NULL, 0, NULL, 0, &nOutput
, NULL))
return FALSE;
else
return TRUE;
}
MYPHADLL_API bool StopDevice() // = STOP_HANDLE
{
if(DeviceIoControl(hDev,DdDRIVER_IOCTL_STOP,NULL,0,NULL,0,&nOutput,NULL
))
return FALSE;
else
return TRUE;
}
MYPHADLL_API int doRead(int i)
{
return outdata[i];
}
}
// myPhaDll.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "myPhaDll.h"
#include "define.h"
#include "winioctl.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// This is an example of an exported variable
MYPHADLL_API int nMyPhaDll=0;
// This is an example of an exported function.
MYPHADLL_API bool fnMyPhaDll(void)
{
return true;
}
// This is the constructor of a class that has been exported.
// see myPhaDll.h for the class definition
CMyPhaDll::CMyPhaDll()
{
return;
}
extern "C"
{
MYPHADLL_API int myAdd(int a, int b)
{
return a*b;
}
MYPHADLL_API bool InitDevice() // = createfile
{
hDev = CreateFile(LINKNAME,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hDev== INVALID_HANDLE_VALUE)
return FALSE;
else
return TRUE;
}
MYPHADLL_API bool StartDevice() // = START_HANDLE
{
if (!DeviceIoControl(hDev, DdDRIVER_IOCTL_START, NULL, 0, NULL, 0, &nOutput
, NULL))
return FALSE;
else
return TRUE;
}
MYPHADLL_API bool StopDevice() // = STOP_HANDLE
{
if(DeviceIoControl(hDev,DdDRIVER_IOCTL_STOP,NULL,0,NULL,0,&nOutput,NULL
))
return FALSE;
else
return TRUE;
}
MYPHADLL_API int doRead(int i)
{
return outdata[i];
}
}