Y
yisp
Unregistered / Unconfirmed
GUEST, unregistred user!
无法在基于DCOM的Service程序中,创建网络文件夹?
1.服务器 TRemoteDataModule + TService
1.1 服务
type
TTestAppService = class(TService)
private
{ Private declarations }
public
function GetServiceController: TServiceController;
override;
{ Public declarations }
end;
1.2 RemoteDataModule
type
TTestAppInterface = class(TRemoteDataModule, ITestApp)
private
{ Private declarations }
protected
function SaveObjs: WordBool;
safecall;
public
{ Public declarations }
end;
function TTestAppInterface.SaveObjs: WordBool;
var
vPathname:String;
begin
try
CoInitialize(nil);
vPathname := '//Server/Data/Test1';//注意这是一个网络路径
ForceDirectories(vPathname);
result :=DirectoryExists(vPathname);
finally // wrap up
CoUnInitialize;
end;
// try/finally
end;
2.客户端
2.1 调用
DCOMCOnnection1.AppServer.saveObjs;
BTW:
1.直接使用小程序执行ForceDirectories(vPathname)成功;
不存在网络无法访问等可能
2.不使用Service时,可以通过DCOM创建
3.使用Service时,创建一个本地路径没有问题
1.服务器 TRemoteDataModule + TService
1.1 服务
type
TTestAppService = class(TService)
private
{ Private declarations }
public
function GetServiceController: TServiceController;
override;
{ Public declarations }
end;
1.2 RemoteDataModule
type
TTestAppInterface = class(TRemoteDataModule, ITestApp)
private
{ Private declarations }
protected
function SaveObjs: WordBool;
safecall;
public
{ Public declarations }
end;
function TTestAppInterface.SaveObjs: WordBool;
var
vPathname:String;
begin
try
CoInitialize(nil);
vPathname := '//Server/Data/Test1';//注意这是一个网络路径
ForceDirectories(vPathname);
result :=DirectoryExists(vPathname);
finally // wrap up
CoUnInitialize;
end;
// try/finally
end;
2.客户端
2.1 调用
DCOMCOnnection1.AppServer.saveObjs;
BTW:
1.直接使用小程序执行ForceDirectories(vPathname)成功;
不存在网络无法访问等可能
2.不使用Service时,可以通过DCOM创建
3.使用Service时,创建一个本地路径没有问题