The installation has no influence to the work of BlackBox, it is working from any folder or USB-stick.
However during installation there is the files association process in Windows Registry, so if you move BlackBox somethere after installation .odc files will not open.
Code: Select all
MODULE ToolsInstaller;
IMPORT Files, Dialog, WinApi, HostFiles;
CONST
normalInstallation = 0;
serverInstallation = 1;
msgSuccess = "This BlackBox is now the default BlackBox installation.";
msgFailure = "Failed to register this BlackBox as default BlackBox installation";
PROCEDURE Set (IN key, subkey, val: ARRAY OF CHAR);
VAR res: INTEGER; h: WinApi.HKEY;
BEGIN
res := WinApi.RegCreateKeyW(WinApi.HKEY_CLASSES_ROOT, key, h);
IF res = WinApi.ERROR_SUCCESS THEN
res := WinApi.RegSetValueW(h, subkey, WinApi.REG_SZ, val, LEN(val$));
res := WinApi.RegCloseKey(h)
END
END Set;
PROCEDURE SetRegistryValues (IN exe, clientdir: ARRAY OF CHAR);
VAR exedir, opencmd, printcmd: ARRAY 1024 OF CHAR; i: INTEGER;
BEGIN
exedir := exe$;
i := LEN(exedir$);
WHILE (i # 0) & (exedir[i - 1] # "/") & (exedir[i - 1] # "\") DO DEC(i) END;
ASSERT(i # 0, 0);
exedir[i] := 0X;
IF clientdir # "" THEN
opencmd := '"' + exe + '" /USE "' + clientdir + '" /o "%1"'
ELSE
opencmd := '"' + exe + '" /o "%1"'
END;
printcmd := '"' + exe + '" /p "%1"';
(* odc files *)
Set(".odc", "", "odcfile");
Set(".odc\ShellNew", "FileName", '"' + exedir + 'Empty.odc"');
Set("odcfile", "", "BlackBox Document");
Set("odcfile\DefaultIcon", "", exe + ",1");
Set("odcfile\shell\open\command", "", opencmd);
Set("odcfile\shell\print\command", "", printcmd);
(* osf files *)
Set(".osf", "", "osffile");
Set("osffile", "", "BlackBox Symbol File");
Set("osffile\DefaultIcon", "", exe + ",2");
Set("osffile\shell\open\command", "", opencmd);
Set("osffile\shell\print\command", "", printcmd);
(* ocf files *)
Set(".ocf", "", "ocffile");
Set("ocffile", "", "BlackBox Code File");
Set("ocffile\DefaultIcon", "", exe + ",3");
Set("ocffile\shell\open\command", "", opencmd);
Set("ocffile\shell\print\command", "", printcmd);
(* OLE support *)
Set("BlackBox.View", "", "BlackBox View");
Set("BlackBox.View\CLSID", "", "{00000001-1000-11cf-adf0-444553540000}");
Set("BlackBox.View\protocol\StdFileEditing\server", "", exe);
Set("BlackBox.View\Insertable", "", "");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}", "", "BlackBox View");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\ProgID", "", "BlackBox.View");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\LocalServer32", "", exe);
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\InProcHandler32", "", "ole32.dll");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\DefaultIcon", "", exe + ",1");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\Insertable", "", "");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\AuxUserType\2", "", "BlackBox View");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\AuxUserType\3", "", "BlackBox");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\MiscStatus", "", "529");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\DataFormats\GetSet\0", "", "3,1,32,1");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\verb\-3", "", "Hide,0,0");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\verb\-2", "", "Open,0,0");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\verb\-1", "", "Show,0,0");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\verb\0", "", "&Edit,0,2");
Set("CLSID\{00000001-1000-11cf-adf0-444553540000}\verb\1", "", "&Open,0,2")
END SetRegistryValues;
PROCEDURE Register (installation: INTEGER);
VAR res: INTEGER; exe: ARRAY 256 OF CHAR; loc: Files.Locator;
BEGIN
res := WinApi.GetModuleFileNameW(0, exe, LEN(exe));
IF res # 0 THEN
IF installation = normalInstallation THEN
SetRegistryValues(exe, "");
Dialog.ShowMsg(msgSuccess)
ELSIF installation = serverInstallation THEN
loc := Files.dir.This("");
IF loc IS HostFiles.Locator THEN
SetRegistryValues(exe, loc(HostFiles.Locator).path);
Dialog.ShowMsg(msgSuccess)
ELSE
Dialog.ShowMsg(msgFailure)
END
ELSE HALT(20)
END
ELSE
Dialog.ShowMsg(msgFailure)
END
END Register;
PROCEDURE RegisterNormalInstallation*;
BEGIN
Register(normalInstallation)
END RegisterNormalInstallation;
PROCEDURE RegisterServerInstallation*;
BEGIN
Register(serverInstallation)
END RegisterServerInstallation;
END ToolsInstaller.