dll怎么用
请各位大虾帮帮忙,小弟以前都没有及出国dll,现在由于学习需要,遇到一个难题——如何将BMP文件转换为JPEG文件。网上查到说用IJL15.DLL 会比较方便。但是小弟不知道应该怎么用DLL文件,还请各位大虾指点。特别是IJL15.DLL的用法
[解决办法]
可以用下列函数直接调用dll
LoadLibrary()
GetProcAddress()
FreeLibrary()
[解决办法]
/*TW04显示屏DLL*/HINSTANCE LPRSEDLL,HDQUEDLL;HINSTANCE TW04Dll;bool loadLPRDLL=false,loadHDDLL=false;bool LoadTW04=false;LPRDEVICEINFO m_DevInfo[100]; //设备信息extern "C"{ int (__stdcall *NetShut)(int LocalPort,char *DescIP,int index); int (__stdcall *NetSendPicData) (int LocalPort,char* DescIP,int CommandByte ,HDC GDC,int Width, int Height, int PColorSign, int SendMode ); int (__stdcall * NetListSend)(int LocalPort,char *DescIP, Byte buff[256],int bufflen); int (__stdcall * NetSendPicOnce)(int LocalPort,char * DescIP,HDC GDC,int Width, int Height, int PColorSign, int SendMode, int showmode, int showspeed, int showtime); int (__stdcall *NetCheckDateTime)(int LocalPort,char* DescIP,int checkValue); int (__stdcall *NetSetLightness)(int LocalPort,char* DescIP,int lightValue); int (__stdcall *NetIPSet)(int LocalPort,char *DescIP,int NewPort,char *NewIP); int (__stdcall *NetCardParamGet)(int LocalPort,char *DescIP, Byte buff[256]); int (__stdcall *ClearMemory)(); long (__stdcall *NetListSendType)(long LocalPort , char *DescIP , unsigned char* buff ,long arrlen,long bufflen); HDC (__stdcall *GDCCreate)(int Width,int Height); int (__stdcall *GDCFree)(HDC GDC); int (__stdcall *DrawRectString)(HDC GDC,char *UserData,char *FontName,int FontSize,int FontColor,int Left,int Top,int Width,int Height); }//-----------bool __fastcall TMainFrm::LoadTW04DLL(){ try { TW04Dll=::LoadLibrary(".//EV_SocketUdpDll.DLL"); if(TW04Dll) { NetShut=(int (__stdcall *)(int LocalPort,char *DescIP,int index))GetProcAddress(TW04Dll,"NetShut"); NetSendPicData=(int (__stdcall *) (int LocalPort,char* DescIP,int CommandByte ,HDC GDC,int Width, int Height, int PColorSign, int SendMode ))GetProcAddress(TW04Dll,"NetSendPicData"); NetListSend=(int (__stdcall * )(int LocalPort,char *DescIP, Byte buff[256],int bufflen))GetProcAddress(TW04Dll,"NetListSend"); NetSendPicOnce=(int (__stdcall * )(int LocalPort,char * DescIP,HDC GDC,int Width, int Height, int PColorSign, int SendMode, int showmode, int showspeed, int showtime))GetProcAddress(TW04Dll,"NetSendPicOnce"); NetCheckDateTime=(int (__stdcall *)(int LocalPort,char* DescIP,int checkValue))GetProcAddress(TW04Dll,"NetCheckDateTime"); NetSetLightness=(int (__stdcall *)(int LocalPort,char* DescIP,int lightValue))GetProcAddress(TW04Dll,"NetSetLightness"); NetIPSet=(int (__stdcall *)(int LocalPort,char *DescIP,int NewPort,char *NewIP))GetProcAddress(TW04Dll,"NetIPSet"); NetCardParamGet=(int (__stdcall *)(int LocalPort,char *DescIP, Byte buff[256]))GetProcAddress(TW04Dll,"NetCardParamGet"); ClearMemory=(int (__stdcall *)())GetProcAddress(TW04Dll,"ClearMemory"); NetListSendType=(long (__stdcall *)(long LocalPort , char *DescIP , unsigned char* buff ,long arrlen,long bufflen))GetProcAddress(TW04Dll,"NetListSendType"); GDCCreate=(HDC (__stdcall *)(int Width,int Height))(TW04Dll,"GDCCreate"); GDCFree=(int (__stdcall *)(HDC GDC))(TW04Dll,"GDCFree"); DrawRectString=(int (__stdcall *)(HDC GDC,char *UserData,char *FontName,int FontSize,int FontColor,int Left,int Top,int Width,int Height))(TW04Dll,"DrawRectString");//DrawRectString return true; } return false; } catch(...) { return false; } return true;}//--------void __fastcall TMainFrm::InitTW04(){ try { LoadTW04=LoadTW04DLL(); if(LoadTW04) { int ret=NetShut(LEDIpPort,LedIp.c_str(),1); //功能:开关屏控制。 参数:index:0:关屏,1,开屏 // PICHDC=GDCCreate(144,56); if(ret==0) InfoLedEdt->Text="开屏成功!"; else InfoLedEdt->Text="开屏失败!"; } } catch(...) { // }}void __fastcall TMainFrm::UnInitTW04(){ try { ClearMemory(); } catch(...) { // }}
[解决办法]
隐式调用:
implib 成lib文件,add进project进行编译
显式调用:
HMODULE Lhandle=LoadLibrary("path");
HANDLE Fhandle=GetProcAddress("function name");
FreeLibrary(Lhandle);