📄 subject_39115.htm
字号:
<p>
序号:39115 发表者:shawrie 发表日期:2003-05-08 11:25:58
<br>主题:得分好机会,这个问题你一定可以回答
<br>内容:STDMETHODIMP Ctom::Fx(BSTR t)<BR>{<BR> char *str;//convert to char *<BR> str=_com_util::ConvertBSTRToString(t);<BR> return S_OK;<BR>}<BR>//上有#include <comutil.h><BR>是一个实验性的COM,VC下,很简单。<BR>建造过程:ATL COM工程--》INSERT ATL SIMPLE OBJECT --》ADD METHOD FX(参数为BSTR T) -》然后想把T转为char*指针。<BR>有如下错:“<BR>LINK : warning LNK4199: /DELAYLOAD:mtxex.dll ignored; no imports found from mtxex.dll<BR>tom.obj : error LNK2001: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(unsigned short *)" (?ConvertBSTRToString@_com_util@@YGPADPAG@Z)<BR>Debug/shawrie.dll : fatal error LNK1120: 1 unresolved externals<BR>Error executing link.exe.<BR>shawrie.dll - 2 error(s), 1 warning(s)<BR>"<BR>主要是两个错误不明白什么含义,应该是很简单的东西啊!<BR><BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:布什去吃屎 回复日期:2003-05-08 11:37:24
<br>内容:char *str为空<BR>为 char str[1024];试试
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:shawrie 回复日期:2003-05-08 20:22:17
<br>内容:不行,不能成功,但错误不同<BR><BR>能告诉我那两个错误是什么含义吗?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:笑笑生 回复日期:2003-05-09 19:54:50
<br>内容:在msdn上找到的,好像跟你的错误有关,看不太懂,自己研究研究吧。<BR>在vc6带的msdn里输入comutil.h查找就能找到这篇文章。<BR><BR><BR>FIX: Function Prototypes in comutil.h Missing Calling Convention<BR>Last reviewed: December 18, 1997<BR>Article ID: Q168003 <BR>The information in this article applies to: <BR>Microsoft Visual C++, 32-bit Editions, version 5.0 <BR><BR><BR>SYMPTOMS<BR>Unresolved external errors may occur when you compile with a default calling convention of __fastcall (/Gr) or __stdcall (/Gz) and call ConvertStringToBSTR or ConvertBSTRToString. <BR><BR><BR><BR>CAUSE<BR>The prototypes are missing the __cdecl calling convention, which is the calling convention of these functions in comsupp.lib. <BR><BR><BR><BR>RESOLUTION<BR>Build with __cdecl as the default calling convention. Do not build with __fastcall or __stdcall as the default calling convention. <BR><BR><BR><BR>STATUS<BR>Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Visual Studio 97 Service Pack 1. <BR><BR>For additional information about the Visual Studio 97 Service Pack 1, please see the following article in the Microsoft Knowledge Base: <BR><BR><BR> ARTICLE-ID: Q170365<BR> TITLE : INFO: Visual Studio 97 Service Packs - What, Where, and Why<BR><BR><BR>MORE INFORMATION<BR><BR><BR>Sample Code<BR><BR> //compile options needed: /Gr or /Gz<BR> #include <comutil.h><BR> int main()<BR> {<BR> char sz[]="hello";<BR> _bstr_t b;<BR> b = _com_util::ConvertStringToBSTR(sz);<BR> char * p = _com_util::ConvertBSTRToString(b);<BR> return 1;<BR> }<BR><BR><BR>The following linker errors occur when you compile this sample code: <BR><BR> error LNK2001: unresolved external symbol "char * __fastcall<BR> _com_util::ConvertBSTRToString(unsigned short *)"<BR> (?ConvertBSTRToString@_com_util@@YIPADPAG@Z)<BR><BR> error LNK2001: unresolved external symbol "unsigned short * __fastcall<BR> _com_util::ConvertStringToBS<BR> TR(char const *)" (?ConvertStringToBSTR@_com_util@@YIPAGPBD@Z)<BR><BR> <BR><BR><BR>--------------------------------------------------------------------------------<BR><BR>Additional query words: LNK2001<BR>Keywords : vcbuglist500 VS97FixlistSP3 kbcode VS97FixlistSP2 VS97FixlistSP1<BR>Version : 5.0<BR>Platform : NT WINDOWS<BR>Issue type : kbbug<BR>Solution Type : kbfix kbservicepack<BR><BR><BR>THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. <BR><BR>Last reviewed: December 18, 1997 <BR>&copy; 1998 Microsoft Corporation. All rights reserved. Terms of Use.<BR> <BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:shawrie 回复日期:2003-05-10 09:33:42
<br>内容:非常感谢两位大哥,尤其是笑笑生先生。<BR>上边这个问题已经解决,又有新问题了,你们一样可以回答:<BR>----------------------------------------------<BR>是一个实验性的COM,VC下,很简单。<BR>建造过程:ATL COM工程--》INSERT ATL SIMPLE OBJECT --》ADD METHOD FX(参数为[in]BSTR T,[out]BSTR* T2) -》然后把T转为char*指针[这回是通过_bstr_t的构造函数很容易实现了],用T2返回。<BR>生成组件test.tom,然后在ASP页面中调用为com变量。页面(process.asp)用set com=nothing结尾,我想用它来清除已用组件内存。但发现,紧跟着修改组件源程序(test.dsw)后,再build test.dll时不能成功,[[错误是:test.dll在使用中,不能打开]]。此时我已停止IIS。<BR>----------------------------------------------<BR>问题1:<BR>这个错误 是不是由于在PROCESS。ASP中调用的组件对象没有清除的缘故,而单纯SET COM=NOTHING及停止IIS不能实现这一点?<BR>----------------------------------------------<BR>如果是这样的话,请继续向下看:<BR>问题2:<BR>停止IIS也不能清除SERVER的组件对象吗?<BR>------------if so ,go on<BR>问题3:最重要 <BR>是不是应该 象那些ASP内置对象,如RECORDSET一样,有CLOSE方法?<BR>所以我又在组件中添了一个方法(因为此时TEST。DLL不能打开,又重起机器才能BUILD,好郁闷)CLOSE,函数体是DELETE THIS;这样可以吗?<BR>或有什么好的方法?<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -