| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- unit ScOpenAPI;
- interface
- uses
- Windows, Forms, Classes, ScProject, ScConfig, ScConsts;
- type
- TScRegisterProc = function(App: TApplication): Boolean;
- IScMenu = interface
- ['{FF358C40-4275-456B-BB95-D82CC2CC79BF}']
- procedure AddMenuItem(const APath: string; AHandle: TNotifyEvent);
- end;
- TScCreateProjectMode = (cpmOpen, cpmNew, cpmImportWCost, cpmImportZBFile);
- IScProjManager = interface
- ['{41A65667-0FCB-4B3F-BC98-8F4FD727FD3B}']
- function Open(AMode: TScCreateProjectMode; AFileName: string = ''; APType: TScProjType = ptBills): TScProject;
- function GetCurProject: TScProject;
- function Version: Integer;
- function GetConfigInfo: TScConfigInfo;
- procedure LockViews;
- procedure UnLockViews;
- property ConfigInfo: TScConfigInfo read GetConfigInfo;
- property CurProject: TScProject read GetCurProject;
- end;
- procedure ScRegisterMenu(const MenuPath: string; Handle: TNotifyEvent);
- function ScLoadPlugInModule(const APath, AProcName: string): Integer;
- var
- MainApp: TApplication;
- implementation
- uses SysUtils, Menus, ScUtils;
- procedure ScRegisterMenu(const MenuPath: string; Handle: TNotifyEvent);
- var
- StrList: TStringList;
- s: string;
- I: Integer;
- Item: TMenuItem;
- vItem: TMenuItem;
- begin
- StrList := TStringList.Create;
- try
- StrList.Delimiter := '\';
- StrList.DelimitedText := MenuPath;
- Item := MainApp.MainForm.Menu.Items;
- for I := 0 to StrList.Count - 1 do
- begin
- if StrList[I] = '' then Continue;
- vItem := Item.Find(StrList[I]);
- if vItem = nil then
- begin
- vItem := TMenuItem.Create(Item.Owner);
- vItem.Caption := StrList[I];
- Item.Add(vItem);
- end;
- Item := vItem;
- end;
- vItem.OnClick := Handle;
- finally
- StrList.Free;
- end;
- end;
- function ScLoadPlugInModule(const APath, AProcName: string): Integer;
- var
- slFiles: TStringList;
- I: Integer;
- sName: string;
- hModule: THandle;
- Proc: TScRegisterProc;
- begin
- slFiles := TStringList.Create;
- try
- ScFindFiles(slFiles, APath);
- for I := 0 to slFiles.Count - 1 do
- begin
- try
- sName := slFiles[I];
- hModule := LoadLibrary(PChar(sName));
- @Proc := GetProcAddress(hModule, PChar(AProcName));
- if (@Proc = nil) or (not Proc(Application)) then
- FreeLibrary(hModule);
- except
- Application.HandleException(Application);
- end;
- end;
- finally
- slFiles.Free;
- end;
- end;
- var
- OrgApp: TApplication;
- initialization
- OrgApp := Application;
- finalization
- Application := OrgApp;
- end.
|