Try this Yuriy -
MapBasic:
++++++++
Declare Sub ConnectToMI Lib "miex2.dll" (ByVal DispId As integer)
Declare Function TestConnect Lib "miex2.dll" () as integer
Declare Sub Main
sub main
call ConnectToMI(SystemInfo(17)) '17 == SYS_INFO_APPIDISPATCH
Note "Number of opened tables: " + TestConnect()
end sub
Delphi:
++++++
library MiEx2;
uses
comobj,
sysutils;
var
MI : Variant;
procedure ConnectToMI(DispatchID: IDispatch); stdcall; export;
begin
MI := DispatchID;
end;
function TestConnect : longint; stdcall; export;
begin
try
Result:= MI.Eval('NumTables()')
except
Result:= -1;
end;
end;
exports
ConnectToMI,
TestConnect;
begin
end.
+++++++++
Regards
Bo Thomsen
GeoConsult I/S
Denmark
-----Oprindelig meddelelse-----
Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne af [EMAIL PROTECTED]
Sendt: 1. december 2005 08:03
Til: [email protected]
Emne: [MI-L] dll for mapbasic programm
Hello All!
I write dll with Delphi to work with some Mapbasic application. When i
call this dll rom mb application I want to "connect" with the same
instance of Mapinfo that calls my dll. There is
SystemInfo(SYS_INFO_APPDISPATCH) function in MapBasic, but i can't
understand how to work with this function results.
May be problem is in speciality of building dll, or in my unability to
convert integer value to variant or interface variable to start working
with Mapinfo.
Dll has, for example, 2 procedures:
procedure ConnectToMI(Ipointer: integer); stdcall; export;
begin
// MI - global dll variant variable to communicate with Mapinfo
MI:= IDispatch(Pointer(Ipointer))
end;
function TestConnect : integer; stdcall; export;
begin
// test function returning number of opened tables
try
Result:= MI.Eval('NumTables()')
except
Result:= -1;
end;
end;
-- MapBasic usage of dll procedures
First:
call ConnectToMI(SystemInfo(SYS_INFO_APPDISPATCH))
Second:
Note "Number of opened tables: " + TestConnect()
Hope to "Mapinfo community" help.
With best regards,
Yuriy Fedorinov
Russia, St.Petersburg
###########################################
????????? ????????? F-Secure Anti-Virus for Microsoft Exchange.
????????? ??????? ?? ??????????.
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l