我已经写了一组在正常应用程序中正常工作的插件。但是当我尝试在服务应用程序中使用它们时,我的服务在达到CreateComObject
函数时停止。 我可以在服务应用程序中使用COM插件吗? 这是代码:服务应用程序和com插件
procedure TWCMService.CreateControllerList;
var
List: TAutoFreeList<TController>>;
i: integer;
Plugin: IPluginInterfaces;
begin
try
List := TAutoFreeList<TController>.Create;
DatabaseModule.IBDatabase1.Connected := true;
DatabaseModule.SelectControllers(List);
DatabaseModule.IBDatabase1.Connected := false;
Plugin := CreateComObject(StringToGuid('{F2959AEC-644F-49E4-9012-B9B3BF34B43F}')) as IPluginInterfaces;
for i := 0 to List.Count - 1 do
begin
Plugin.Init(StringToGuid(List[i].PluginId));
FAvailControllers.Add(CreateComObject(Plugin.GetCommunicationPluginGuid) as ICommunicationPlugin);
FAvailControllers[i].Init(Self as IServiceApplication);
FAvailControllers[i].SetMAC(List[i].ControllerMAC);
MessageBox(0, 'Dodany', 'Uwaga', MB_OK);
end;
List.Free;
FAvailControllersCurrentIndex := 0;
Timer1.Enabled := true;
except
raise Exception.Create('WCM Serwis: Error Message');
end;
end;
请正确格式化您的代码。将其粘贴进去,选中它,然后点击{}按钮。 – 2011-03-04 12:48:12