|
꼴.시크릿 님이 쓰신 글 :
: //---------------------------------------
: int WINAPI lockinit(int op1);
:
:
: int lock_init(int op1)
: {
: int result;
: op1=(op1+AD_INIT)*EN_INIT;
: result = lockinit(op1); <---- 이부분은 Dll파일에 정이되어 있는 함수 입니다.
: result = (result/EN_INIT)-AD_INIT;
:
: return (result);
: }
그리고 c소스는 아래와 같으며 프로젝트 파일에 LIB 파일 추가하고 실행하면 컴파일 됩니다.
그런데.. 빌더에서 어떻게 해하 되는지 잘 모르겠네요..
/*---------------------------------------------------------------------------
|
| MEGA.C Copyright (c) Hando Computer 1989-1996.
|
| 메가락 예제 프로그램(DLL for Microsoft Windows9X /ME /NT /2000 /XP)
|
|--------------------------------------------------------------------------*/
#include <windows.h>
#include "lmega.h"
int WINAPI lockinit(int op1);
int WINAPI lockauto(int op1);
int WINAPI lockfunc0(int op1, int op2);
int WINAPI lockfunc1(int op1, int op2);
int WINAPI lockfunc2(int op1, int op2);
int WINAPI lockfunc3(int op1, int op2);
int WINAPI lockwrite(int op1, int op2);
int WINAPI lockread(int op1, int op2); /*
extern "C" bool lockDriverCheck(void);
extern bool MakeWnsdrvrFileAuto(void); */
int lock_init(int op1)
{
int result;
op1=(op1+AD_INIT)*EN_INIT;
result = lockinit(op1);
result = (result/EN_INIT)-AD_INIT;
return (result);
}
int lock_auto(int op1)
{
int result;
op1=(op1+AD_AUTO)*EN_AUTO;
result = lockauto(op1);
result = (result/EN_AUTO)-AD_AUTO;
return (result);
}
int lock_func0(int op1, int op2)
{
int result;
op1=(op1+AD_FUNC0)*EN_FUNC0;
op2=(op2+AD_FUNC0)*EN_FUNC0;
result = lockfunc0(op1, op2);
result = (result/EN_FUNC0)-AD_FUNC0;
return (result);
}
int lock_func1(int op1, int op2)
{
int result;
op1=(op1+AD_FUNC1)*EN_FUNC1;
op2=(op2+AD_FUNC1)*EN_FUNC1;
result = lockfunc1(op1, op2);
result = (result/EN_FUNC1)-AD_FUNC1;
return (result);
}
int lock_func2(int op1, int op2)
{
int result;
op1=(op1+AD_FUNC2)*EN_FUNC2;
op2=(op2+AD_FUNC2)*EN_FUNC2;
result = lockfunc2(op1, op2);
result = (result/EN_FUNC2)-AD_FUNC2;
return (result);
}
int lock_func3(int op1, int op2)
{
int result;
op1=(op1+AD_FUNC3)*EN_FUNC3;
op2=(op2+AD_FUNC3)*EN_FUNC3;
result = lockfunc3(op1, op2);
result = (result/EN_FUNC3)-AD_FUNC3;
return (result);
}
int lock_write(int op1, int op2)
{
int result;
op1=(op1+AD_WRITE)*EN_WRITE;
op2=(op2+AD_WRITE)*EN_WRITE;
result = lockwrite(op1, op2);
result = (result/EN_WRITE)-AD_WRITE;
return (result);
}
int lock_read(int op1, int op2)
{
int result;
op1=(op1+AD_READ)*EN_READ;
op2=(op2+AD_READ)*EN_READ;
result = lockread(op1, op2);
result = (result/EN_READ)-AD_READ;
return (result);
}
int APIENTRY WinMain(HANDLE, HANDLE, LPSTR, int);
BOOL InitApplication(HANDLE);
BOOL InitInstance(HANDLE, int);
LONG APIENTRY MainWndProc(HWND, UINT, UINT, LONG);
void CheckMegaLock(HDC hDC);
HANDLE hInst;
/////////////////////////////////////////////////////////////////////////////
//
// FUNCTION : WinMain(HANDLE, HANDLE, LPSTR, int)
//
// PURPOSE : calls initialization function, processes message loop
//
int APIENTRY WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
if (!hPrevInstance)
if (!InitApplication(hInstance))
return (FALSE);
if (!InitInstance(hInstance, nCmdShow))
return (FALSE);
while (GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}
/////////////////////////////////////////////////////////////////////////////
//
// FUNCTION : InitApplication(HANDLE)
//
// PURPOSE : Initializes window data and registers class
//
BOOL InitApplication(HANDLE hInstance)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "MegaSampWClass";
return (RegisterClass(&wc));
}
/////////////////////////////////////////////////////////////////////////////
//
// FUNCTION : InitInstance(HANDLE, int)
//
// PURPOSE : Saves instance handle and creates main window
//
BOOL InitInstance(HANDLE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance;
hWnd = CreateWindow( "MegaSampWClass", "Mega-Lock for Windows",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL );
if (!hWnd)
return (FALSE);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return (TRUE);
}
/////////////////////////////////////////////////////////////////////////////
//
// FUNCTION : MainWndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE : Processes messages
//
LONG APIENTRY MainWndProc(HWND hWnd, UINT message, UINT wParam, LONG lParam)
{
HDC hDC;
PAINTSTRUCT ps;
switch (message){
case WM_CREATE:
/*
lock_init(0);
if(lock_auto(0) != 0) {
MessageBox(hWnd, "Mega-Lock not found !", "Warning", MB_OK | MB_ICONEXCLAMATION);
DestroyWindow(hWnd);
}
*/
break;
case WM_PAINT:
SetCursor(LoadCursor(NULL, IDC_WAIT));
hDC = BeginPaint(hWnd, &ps);
CheckMegaLock(hDC);
EndPaint(hWnd, &ps);
SetCursor(LoadCursor(NULL, IDC_ARROW));
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return (DefWindowProc(hWnd, message, wParam, lParam));
}
return 0L;
}
/////////////////////////////////////////////////////////////////////////////
//
// FUNCTION : CheckMegaLock(HDC)
//
// PURPOSE :
//
void CheckMegaLock(HDC hDC)
{
int rv;
char szTemp[256];
unsigned char i, j;
SetBkMode(hDC, OPAQUE);
TextOut(hDC, 10, 5, szTemp, wsprintf(szTemp, "MEGA LOCK Ex....Copyright.Hando Computer."));
//____________lock_init() ____ // usb 전용의 경우 0x3ff
rv=lock_init(0); //usb,printer port 겸용
if(rv == 0)
{
TextOut(hDC, 10, 30, szTemp, wsprintf(szTemp, "Mega-Lock not Found !"));
return(FALSE);
}else{
TextOut(hDC, 10, 30, szTemp, wsprintf(szTemp, "Printer Port = 0x%x", rv));
//진행
}
//____________lock_auto()___________________________
if(lock_auto(0) == 0)
{
for(i = 1; i <= 4; i++) {
if(i == 1)
TextOut(hDC, 10, 50, szTemp, wsprintf(szTemp, "Serial No = %x", lock_auto(i)));
else
TextOut(hDC, 10, 50, szTemp, wsprintf(szTemp, "%s %x", szTemp, lock_auto(i)));
}
TextOut(hDC, 10, 70, szTemp, wsprintf(szTemp, "func 0 = %3d(1, 2)", lock_func0(1, 2)));
TextOut(hDC, 10, 90, szTemp, wsprintf(szTemp, "func 1 = %3d(3, 4)", lock_func1(3, 4)));
TextOut(hDC, 10, 110, szTemp,wsprintf(szTemp, "func 2 = %3d(5, 6)", lock_func2(5, 6)));
TextOut(hDC, 10, 130, szTemp,wsprintf(szTemp, "func 3 = %3d(7, 8)", lock_func3(7, 8)));
TextOut(hDC, 10, 150, szTemp, wsprintf(szTemp, "DATA Write"));
for(i = 0; i < 16; i++) {
j = i * 2;
TextOut(hDC, 10 + i * 40, 170, szTemp,
wsprintf(szTemp, "%3d: ", lock_write(i, j)));
}
TextOut(hDC, 10, 190, szTemp, wsprintf(szTemp, "DATA Read"));
for (i = 0; i < 16; i++)
TextOut(hDC, 10 + i * 40, 210, szTemp,
wsprintf(szTemp, "%3d", lock_read(i, 0xff)));
}
else { //LOCK_AUTO실패
TextOut(hDC, 10, 50, szTemp, wsprintf(szTemp, "Mega-Lock not Found !"));
}
}
|