|
C는 잘 모르지만.... 아래 코드가 아닐런지...
hio = LoadLibrary("c:\\...어쩌고...\\io.dll");
맙소사 님이 쓰신 글 :
: 일단 너무 기초적인것 같아 .... 웃지마시고 지도 좀 부탁드립니다.
:
: 제가 터보익스플로러를 사용 하는 어마어마한 초보 입니다.
:
: 제가 하려고 하는것은
:
: io.dll 사용하여 프린트포트로 1출력하고 1초후 다시 0출력하려고 합니다.
:
: > implib io io.dll 해서 lib 말들어서 .lib .h .dll 파일 3개를 소스 폴더에 복사후
:
: add to project 에 lib 파일 선택했습니다.
:
: 폼위에 T버튼과 Tedit 1개씩 있습니다.
:
: 버튼을 누르면 dll 로드해서 실패하면 에디트창에 실패라고쓰고 끝
: 성공하면 프린트포트로 1출력하고 1초후 다시 0출력
:
: 이렇게 하려고 하는데 계속 실패만 나옵니다.
:
: 잘못된 부분좀 알려 주세요...
:
: 아래는 제가 수정한 Unit1.cpp 파일의 내용 입니다. 다른파일은 건드릴게 없습니다.
:
:
: #include <vcl.h>
: #pragma hdrstop
:
: #include "Unit1.h"
:
: #include "io.h"
: #include <dos.h>
:
: #define LPT1add 0x378
:
: PORTOUT PortOut;
: PORTWORDOUT PortWordOut;
: PORTDWORDOUT PortDWordOut;
: PORTIN PortIn;
: PORTWORDIN PortWordIn;
: PORTDWORDIN PortDWordIn;
: SETPORTBIT SetPortBit;
: CLRPORTBIT ClrPortBit;
: NOTPORTBIT NotPortBit;
: GETPORTBIT GetPortBit;
: RIGHTPORTSHIFT RightPortShift;
: LEFTPORTSHIFT LeftPortShift;
: ISDRIVERINSTALLED IsDriverInstalled;
:
:
: HMODULE hio;
:
: void UnloadIODLL()
: {
: FreeLibrary(hio);
: }
: int LoadIODLL()
: {
: hio = LoadLibrary("io");
: if (hio == NULL) return 1;
:
: PortOut = (PORTOUT)GetProcAddress(hio, "PortOut");
: PortWordOut = (PORTWORDOUT)GetProcAddress(hio, "PortWordOut");
: PortDWordOut = (PORTDWORDOUT)GetProcAddress(hio, "PortDWordOut");
: PortIn = (PORTIN)GetProcAddress(hio, "PortIn");
: PortWordIn = (PORTWORDIN)GetProcAddress(hio, "PortWordIn");
: PortDWordIn = (PORTDWORDIN)GetProcAddress(hio, "PortDWordIn");
: SetPortBit = (SETPORTBIT)GetProcAddress(hio, "SetPortBit");
: ClrPortBit = (CLRPORTBIT)GetProcAddress(hio, "ClrPortBit");
: NotPortBit = (NOTPORTBIT)GetProcAddress(hio, "NotPortBit");
: GetPortBit = (GETPORTBIT)GetProcAddress(hio, "GetPortBit");
: RightPortShift = (RIGHTPORTSHIFT)GetProcAddress(hio, "RightPortShift");
: LeftPortShift = (LEFTPORTSHIFT)GetProcAddress(hio, "LeftPortShift");
: IsDriverInstalled = (ISDRIVERINSTALLED)GetProcAddress(hio, "IsDriverInstalled");
:
: atexit(UnloadIODLL);
:
: return 0;
: }
:
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner)
: : TForm(Owner)
: {
: }
: //---------------------------------------------------------------------------
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
: unsigned char ttt;
:
: if(LoadIODLL())
: Edit1->Text="DLL 링크 실패";
: else {
: Edit1->Text="DLL 링크 성공";
:
: ttt=0x01;
: PortOut(LPT1add, ttt);
:
: Sleep(1);
:
: ttt=0x00;
: PortOut(LPT1add, ttt);
: //
: };
: }
: //---------------------------------------------------------------------------
|