关于WEB程序开发的一个问题(200分)

  • 主题发起人 主题发起人 wingofdark
  • 开始时间 开始时间
W

wingofdark

Unregistered / Unconfirmed
GUEST, unregistred user!
我在用ISAPI做WEB程序时,总是CoInitialize初始化失败,但这些代码在本机运行时就没有问题,还请高人指点一二。
下面是源代码:
procedure TwmWebMain.wmMainwaLoginAction(Sender: TObject;

Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);

var

lUser, lPwd, lClientID : string;

lError: Widestring;

// lIWebServer: IWebServer;

lReturnCode: integer;

begin

lClientID := Request.RemoteAddr + cLogin;

SetClientData(lClientID, False, '');

try

lUser := Request.ContentFields.Values['UserName'];

lPwd := Request.ContentFields.Values['PassWord'];

Response.SetCustomHeader('Cache-Control', 'No-Store');



if lIWebServer <> nil then

begin

Response.Content := ' is nul';

end

else

Response.Content :=' oked';



exit;

//OleCheck(

try







OleCheck(CoCreateInstance(CLASS_WebServer, nil, CLSCTX_INPROC_SERVER or

CLSCTX_LOCAL_SERVER,IID_IWebServer, lIWebServer)); //错误在此







if lIWebServer = nil then

Response.Content := '创建了,但为空'

else

Response.Content := 'yesed 已创建';

except

if lReturnCode= S_OK then

Response.Content := 'SOK'

else if lReturnCode = REGDB_E_CLASSNOTREG then

Response.Content := 'RegDB_E_ClassNotReg'

else if lReturnCode = E_OUTOFMEMORY then

Response.Content := 'E_OutOfMemory'

else if lReturnCode = E_INVALIDARG then

Response.Content := 'InValidArg'

else if lReturnCode = E_UNEXPECTED then

Response.Content := 'UnExpected'

else if lReturnCode = CLASS_E_NOAGGREGATION then

Response.Content := 'CLASS_E_NOAGGREGATION'

end;



exit;



if not lIWebServer.Login(lUser, lPwd, lError) then

begin

Response.Content :=

'<HTML>'#13 +

'<BODY bgColor="lightblue" >'#13 +

'<a><Font color="red"><I><b>---Web登录未通过服务器的验证,正在试图进行下一次尝试---</b></Font></I></a>'#13 +

'<script>'#13 +

' location = "' + GetURLPath(Request) + 'html/EMP.htm";'#13 +

' if(!(window.confirm("' + lError +',是否重新登录?")))'#13 +

' window.close();'#13 +

'</script>'#13 +

'</BODY>'#13 +

'</HTML>'#13;

end

else

begin

jsSetCookie(Response, lUser, lPwd);

Response.Content := MainMenu.Content;

end;

finally

SetClientData(lClientID, True, '');

Handled := True;

end;

end;
 
设置ComInitiaLization属性为ciMultiThreaded
 
后退
顶部