Hi,
This little Delphi class opens mappoint in background (invisible). It try to open version 2004 Europe first, if not it checks for 2002 version. You eventally have to change the registry search for version 2006 and of course for the US versions also if nececary.
Code:
unit uMP;
interface
uses
Windows, SysUtils, Classes, MapPoint_TLB, Registry, Math;
type
TOnError = procedure(Sender: TObject; E: Exception) of object;
TMapPoint = class
private
FMP: _Application;
FOnError: TOnError;
public
constructor Create(ErrorProc: TOnError);
destructor Destroy; override;
end;
implementation
{ TMapPoint }
constructor TMapPoint.Create(ErrorProc: TOnError);
var
Reg: TRegistry;
FileName: string;
begin
inherited Create;
FOnError := ErrorProc;
try
FMP := CoApplication.Create;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CLASSES_ROOT;
if not Reg.OpenKey('.ptm\MapPoint.Map.EU.11\ShellNew', False) then
if not Reg.OpenKey('.ptm\MapPoint.Map.EU.9\ShellNew', False) then
Exit;
FileName := Reg.ReadString('FileName');
FMP.OpenMap(FileName, False);
finally
Reg.Free;
end;
except
on E: Exception do
if Assigned(FOnError) then
FOnError(Self, E);
end;
end;
destructor TMapPoint.Destroy;
begin
FMP.ActiveMap.Saved := True;
FMP.Quit;
inherited;
end;