main.cpp
上传用户:seepec
上传日期:2020-01-16
资源大小:183k
文件大小:1k
- #include <windows.h>
- #include <cstdlib>
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- #include "stdafx.h"
- //#include "lib_victorcoasne_com.hpp"
- using namespace std;
- typedef short _stdcall ( * InputProcedure )( short );
- typedef short _stdcall ( * OutputProcedure )( short, short );
- //short _stdcall Inp32(short PortAddress);
- //void _stdcall Out32(short PortAddress, short data);
- int main( void )
- {
- HMODULE library = LoadLibrary( "inpout32.dll" );
- if( library )
- {
- InputProcedure Inp32 = ( InputProcedure )GetProcAddress( library, "Inp32" );
- OutputProcedure Out32 = ( OutputProcedure )GetProcAddress( library, "Out32" );
- if( Inp32 && Out32 )
- {
- short OutputVal=0;
- cout<<"Input the data:";
- cin>>OutputVal;
- Out32( 0x378, OutputVal );
- short PortVal = Inp32( 0x378 );
- cout << "recieved from port: " << PortVal << endl;
- }
- else
- {
- cerr << "GetProcAddress failed" << endl;
- }
- FreeLibrary( library );
- }
- else
- {
- cerr << "LoadLibrary failed" << endl;
- }
- system("pause");
- return 0;
-
- }