Please pay attention! This method can only be applied to the __stdcall call mode of the output of the C format!
1. Use the VC tool Dumpbin to export the export function table in the DLL to a definition (.def) file EXAMPLE: DUMPBIN VIDEODECODECODLL / EXPROTS /OUT :VIDEODECODER.DEF 2. The exported .def file will be constructed as one. DEF function of the number of exported file EXAMPLE: VideoDeCoder.DEF document reads as follows Dump of file VideoDeCoder.dll file Type: DLL Section contains the following exports for VideoDeCoder.dll 0 characteristics 3D49E48F time date stamp Fri Aug 02 09:46:55 2002 0.00 Version 1 Ordinal Base 11 Number of Functions 11 number of names ordinal hint RVA name 1 0 00010F60 _TM_ClearDecoderBuff @ 4 2 1 00010E80 _TM_CloseDecoder @ 4 3 2 00010F00 _TM_DecodePicture @ 4 4 3 00010ED0 _TM_DecodePictureHeader @ 4 5 4 00010FD0 _TM_GetFileEnd @
4 6 5 00011030 _TM_GetUValue @ 4 7 6 00011060 _TM_GetVValue @ 4 8 7 00011000 _TM_GetYValue @ 4 9 8 00010E10 _TM_OpenDecoder @ 8 10 9 00010F30 _TM_ReturnType @ 4 11 A 00010F90 _TM_SetFileEnd @ 8 Summary 2000 .data 1000 .rdata 1000 .reloc 15000 .text Follow the following methods: 1> Add libly ilbrary "videodecoder" "XX" is DLL Name Description "VideoDecoder Library" 2> Remove the content other than the export function indicating that the "exprots" instructions are added to the lib description Export function library "VideoDeodecoder" Description "VideoDecoder Library"
EXPORTS ordinal hint RVA name 1 0 00010F60 _TM_ClearDecoderBuff @ 4 2 1 00010E80 _TM_CloseDecoder @ 4 3 2 00010F00 _TM_DecodePicture @ 4 3 00010ED0 _TM_DecodePictureH 5 4 00010FD0 _TM_GetFileEnd @ 4 6 5 00011030 _TM_GetUValue @ 4 7 6 00011060 _TM_GetVValue @ 4 8 7 00011000 _TM_GetYValue @ 4 9 8 00010E10 _TM_Opendecoder @ 8 10 9 00010f30 _TM_RETURNTYPE @ 4 11 a 000f90 _tm_setfilend @ 8 3> Put all the functions to the head, remove "hint" and "rva" data, leave the serial number "Ordinal" of the function, in the serial number Plus "@" symbol formation "_ export function name @ parameter byte and @ serial number" (__stdcall mode call export function symbol is "function name @ parameter byte and"). Finally, the .def file is as follows : Library "videodecoder" Description "VideoDeodecoder Library"
EXPORTS TM_ClearDecoderBuff @ 4 @ 1 TM_CloseDecoder @ 4 @ 2 TM_DecodePicture @ 4 @ 3 TM_DecodePictureHeader @ 4 @ 4 TM_GetFileEnd @ 4 @ 5 TM_GetUValue @ 4 @ 6 TM_GetVValue @ 4 @ 7 TM_GetYValue @ 4 @ 8 TM_OpenDecoder @ 8 @ 9 TM_ReturnType @ 4 @ 10 TM_SETFILEEND @ 8 @ 11 3. Use the VC LIB tool, with /def: (.def file name) / machine: IX86 (80x86 machine), output the lib file in accordance with the VC format. EXAMPLE: LIB / DEF: VideoDecoder.def / Machine: IX864.Press the lib file link; note that when some dynamic library DUMPBIN is only function name, there is no "@nn" parameter format, such as C Builder written DLL, the output is only The function name symbol, the link will be reported: Error LNK2002: Unresolved External Symbol "FunctionName @ nn" prompt that the function symbols introduced in the program cannot be identified, then just change the corresponding function name in the DEF file to functionname @ nn mode, re- Establish LIB, re-link.
This makes it a LIB that meets the VC call mode!
Reference: MSDN2000
It is worth mentioning! Borland C Builder has a good tool impdef to directly output functions in the DLL to the .def file, as long as you do a little modification, you can become a VC file!
IMPDEF XXX.DEF XXX.DLL
This approach can only be applied to the __stdcall call mode of the output of the C format, has some mistakes in my argument! I use Borland C and VC to argue, discover:
In C Builder! __CDECL's function output will bring one "__ stdcall without feature, only output function name __fastcall function output with a" @nn "suffix format before outputting one" @nn "suffix format! In VC! __CDECL no feature, only output function name __stdcall function output a "_" suffix "@nn" __ fastcall function output before outputting a "@" suffix "@nn
Just use the lib tool to generate lib tools as long as the function in which the function in the DEF file of the BC is converted to the VC recognition, can be used to generate lib tools; use C-tare output (Extern "C") is essential! And don't forget that the function in the DEF file is declared not to bring "_"! :) Otherwise there will be a link error of Error LNK2001!
If you want to call the VC's DLL, you want to change the DEF file to the format that conforms to CB call habits: first use impDef to export DEF files, modify VC CB @ fastcall @ nn @fastcallcdeclCall_cdeclcall then Implib can not change I found such The method can also be adapted to the C style compiled DLL, but can only be used in the same language development tool! :)