在要服務端建立共享池才可以,方法一(效果不太好):
class procedure TProviders.UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSpooling(ClassID);//不知道對不對,好久沒有搞三層
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
DisableSpooling(ClassID);//不知道對不對,好久沒有搞三層
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
方法二:
Function RegisterClient(ClientID: Integer;
AcctName, DBConnStr, UserID: String;
DepartID: Integer): Boolean;
var SPM: ISharedPropertyGroupManager;
pg: ISharedPropertyGroup;
sp: ISharedProperty;
LockMode, RelMode: Integer;
Exist: WordBool;
pgName: WideString;
begin
SPM := CreateSharedPropertyGroupManager;
pgName := 'AccountInfo:'+sAppName+':'+AcctName;
LockMode := LockSetGet;
RelMode := Process;
pg := SPM.CreatePropertyGroup(pgName, LockMode, RelMode, Exist);
if not Exist then
begin
sp := pg.CreateProperty('AccountName', Exist);
sp.Value := AcctName;
sp := pg.CreateProperty('ConnStr', Exist);
sp.Value := DBConnStr;
end;
pgName := 'ClientInfo:'+sAppName+':'+IntToStr(ClientID);
LockMode := LockSetGet;
RelMode := Process;
pg := SPM.CreatePropertyGroup(pgName, LockMode, RelMode, Exist);
if not Exist then
begin
sp := pg.CreateProperty('AccountName', Exist);
sp.Value := AcctName;
sp := pg.CreateProperty('UserID', Exist);
sp.Value := UserID;
sp := pg.CreateProperty('DepartID', Exist);
sp.Value := DepartID;
end;
Result := true;
end;