📄 main.cpp
字号:
#include <windows.h>
//#include "Win32Dll.h"
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
#define DOGCHECK 1
#define READDOG 2
#define WRITEDOG 3
#define BOGUSREAD 4
#define BOGUSWRITE 5
#define GETCURRENTNO 6
#define COMPARE 7
#define OPERATION 8
#define WRITEEXPRESSIONS 9
#define WRITEONLY 10
#define DISABLESHARE 11
#define ENABLESHARE 12
#define DllFileName "Win32Dll.Dll"
#define DllFunction "GS_QADog"
#ifndef ULONG
#define ULONG unsigned long
#endif
#ifndef HUINT
#define HUINT unsigned short
#endif
#ifndef UCHAR
#define UCHAR unsigned char
#endif
#ifndef WORD
#define WORD unsigned short
#endif
#define MHSTATUS ULONG
#pragma pack(1)
typedef struct _QA_DLL_PARA
{
BYTE Command;
BYTE DogCascade;
BYTE OperationNo;
WORD DogAddr1;
WORD DogAddr2;
WORD DogBytes;
DWORD DogPassword;
DWORD DogResult;
BYTE DogData[200];
}QA_DLL_PARA, * PQA_DLL_PARA;
#pragma pack()
#pragma argsused
extern "C" __declspec(dllexport) unsigned long __stdcall CheckFace(long,int);
extern "C" __declspec(dllexport) unsigned long __stdcall Operation();
//extern "C" __declspec(dllexport) unsigned long __stdcall WriteDog(void);
extern "C" __declspec(dllexport) unsigned long __stdcall GetString(long,int,int,int,char*);
/*
extern "C" __declspec(dllexport) unsigned long __stdcall GetCurrentNo(void);
extern "C" __declspec(dllexport) unsigned long __stdcall DisableShare(void);
extern "C" __declspec(dllexport) unsigned long __stdcall WriteOnly(void);
extern "C" __declspec(dllexport) unsigned long __stdcall BogusWrite(void);
extern "C" __declspec(dllexport) unsigned long __stdcall BogusRead(void);
extern "C" __declspec(dllexport) unsigned long __stdcall WriteExpressions(void);
extern "C" __declspec(dllexport) unsigned long __stdcall DogCompare();
*/
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
unsigned long __stdcall CheckFace(long aiPwd,int aiCasCade)
{ QA_DLL_PARA dogPara;
dogPara.Command = DOGCHECK;
dogPara.DogPassword = aiPwd;
dogPara.DogCascade = aiCasCade;
HINSTANCE hInst;
hInst = LoadLibrary(DllFileName);
long __stdcall (*GS_QADog)(PQA_DLL_PARA) = (long (__stdcall*)(PQA_DLL_PARA))GetProcAddress(hInst,DllFunction);
int iRet = GS_QADog(&dogPara);
FreeLibrary(hInst);
return iRet;
}
unsigned long __stdcall GetString(long aiPwd,int aiCasCade,int aiReadAddr1,int aiReadBytes,char* pBuff)
{ QA_DLL_PARA dogPara;
dogPara.Command = READDOG;
dogPara.DogPassword = aiPwd;
dogPara.DogCascade = aiCasCade;
dogPara.DogAddr1 = aiReadAddr1;
dogPara.DogBytes = aiReadBytes;
HINSTANCE hInst;
hInst = LoadLibrary(DllFileName);
long __stdcall (*GS_QADog)(PQA_DLL_PARA) = (long (__stdcall*)(PQA_DLL_PARA))GetProcAddress(hInst,DllFunction);
int iRet = GS_QADog(&dogPara);
FreeLibrary(hInst);
if(iRet == 0) memcpy(pBuff,dogPara.DogData,aiReadBytes);
return iRet;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -