将 CString 传递给 ISAPI 扩展中的 IIS ServerSupportFunction 函数
我得到了一个在 VC6 中编译的 ISAPI 扩展 dll,它通过 MFC 的 CHttpServerContext 类调用“ServerSupportFunction”。 当在 windows 2003 IIS6 上运行时,代码看起来像这样(假设 Ctx 是 CHttpServerContext 类的对象)
CString str;
str = "Content-Type: text/plain\r\n";
str += "Content-Length: 200\r\n";
str += "\r\n";
DWORD len = str.GetLength();
Ctx->ServerSupportFunction(HSE_REQ_SEND_RESPONSE_HEADER,NULL,
&len,
(LPWORD)(LPCTSTR)str);
,此代码工作正常。如果运行于 它会返回 Windows 错误代码 ERROR_INVALID_PARAMETER
windows 2008 IIS7如果我将最后一个参数更改为 (LPWORD)“Content-Type: text/plain\r\n\r\n”, 代替使用 CString ,函数调用成功。 该dll是在windows xp下用VC6用静态MFC编译的。
由于我不愿意更改dll代码,有谁知道Windows 2008中出现此问题的原因以及如何解决它?
Windows 2008 中是否有任何变化影响了这一点? (我没有找到) 它可能与机器代码页有关吗? dll 应该以不同的方式编译吗?(也许没有 UNICODE)
I've been given an ISAPI extension dll compiled in VC6 which calls "ServerSupportFunction" through MFC's CHttpServerContext class.
The code looks something like (assume Ctx is object of the class CHttpServerContext)
CString str;
str = "Content-Type: text/plain\r\n";
str += "Content-Length: 200\r\n";
str += "\r\n";
DWORD len = str.GetLength();
Ctx->ServerSupportFunction(HSE_REQ_SEND_RESPONSE_HEADER,NULL,
&len,
(LPWORD)(LPCTSTR)str);
when running on windows 2003 IIS6 , this code works fine. If running on
windows 2008 IIS7 it returns a windows error code of ERROR_INVALID_PARAMETER
if i change the last parameter to be (LPWORD)"Content-Type: text/plain\r\n\r\n"
instaed of using CString , the function call succeed.
The dll is compiled in windows xp with VC6 with static MFC .
Since i reluctant to change the dll code , does anyone know of a reason why this problem occurs in windows 2008 and how it can be solved?
Was there any change in windows 2008 affecting this? (I didn't found any)
Can it be related to the machine codepage? Should the dll compiled differenatly?(maybe without UNICODE)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了问题。发送的原始代码的字符串是
“HTTP/1.0 200 OK\r\n内容类型:文本/纯文本\r\n....”
当“HTTP/1.0 200 OK\r\n”被删除并且该字符串仅包含 HTTP 标头时,调用工作得非常好。
I found the problem. The string the original code sent was
"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n...."
When the "HTTP/1.0 200 OK\r\n" was removed , and the string contained only HTTP headers , the call worked perfectly well.