Pierre - You can use the functions from MapBasic with the "mangled" names:
When you compile the functions with __stdcall in vc 6.0 you'll get the following "name decoration" : 1) the function name gets prefixed with "_" 2) the function name get postfixed with "@nn" where nn is the size in bytes of the all the function arguments. Strings is always transferred from MapBasic as char pointers, and pointers are 4 bytes example (from MITAB opensource library to read and write binary tab-files) : Declare Function mitab_c_get_text_vb Lib "mitab.dll" Alias "_mitab_c_get_text_vb@12" (ByVal feature As Integer, ByVal text As String, ByVal l As Integer) As Integer mitab_c_get_text_vb becomes: _mitab_c_get_text_vb@12 size of argumentlist: 1 Mapbasic Integer, (4 bytes) + 1 textstring, pointer (4 bytes) + 1 MapBasic Integer( 4 bytes) = 12 Bytes regards Bo Thomsen GeoConsult -----Oprindelig meddelelse----- Fra: HENROTAY PIERRE [mailto:[EMAIL PROTECTED]] Sendt: 4. december 2002 11:26 Til: '[EMAIL PROTECTED]' Emne: MI-L DLLs and MapBasic: calling convention ? (2) I was asking recently the following question (thanks to Warren Vick and Bo Thomsen for their input !) "I am creating DLLs in VC++, to be called from MB. By default, the argument uses the __cdecl argument passing convention (caller pops the stack). Is this OK or should I use __stdcall (the Pascal convention, called function pops the stack)." I need to add a few more info: 1) The DLLs are supposed to be accessible from MB, VB(A), C/C++ etc... 2) VBA cannot use DLLs with the __cdecl calling convention (Knowledge Base Article 213554): this leads to error 49, "Bad DLL calling convention"; __stdcall is required (which is the case for most 32 bits DLL included with Windows). 3) The MB user guide says (chapter 10) nothing about whether __stdcall or __cdecl should be used, only to not use __fastcall. It does not say that MB (caller) is able to pop the stack; if not properly done, this is likely lead to problems at some time. So my present conclusion is that __stdcall is required. Problem is that this convention leads to name decoration (name is postfixed with @ and number of bytes for arg list). A VC++ DEF file is thus required to get the proper final name. Still investigating on this. Pierre Henrotay Siemens Information and Communications Siemens Business Services s.a./n.v. --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 4412 --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 4414
