📄 subject_64007.htm
字号:
<p>
序号:64007 发表者:freeaward 发表日期:2003-12-08 12:17:36
<br>主题:不能创建MSCOMM!
<br>内容:我用MSCOMM32进行串口通信<BR>在MainFrm.h中声明:<BR>CMSComm m_com;<BR>在MainFrm.cpp 中创建控件:<BR>if(!m_com.Create(NULL,WS_VISIBLE|WS_CHILD,CRect(0,0,0,0),this,ID_COMMCTRL))<BR>{<BR> MessageBox("不能创建MSCOMM!");<BR> return -1;<BR>}<BR>问题:<BR>在安装了VC的计算机上不会有问题,但打包后到其它计算机上用就会出现“不能创建MSCOMM!"的错误,我基本上将要用的控件和动态连接库全部都打包了,而且将程序设为静态连接,还是有这样的错误,为什么??
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:doggo 回复日期:2003-12-08 12:27:37
<br>内容:我记得mscomm是个ocx,你的机器在安装VC的时候安装了,其他及其可能没有安装。或者对应的版本有问题。你把你及其上的mscomm拷贝到其他机器上再注册一下就可以了。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:freeaward 回复日期:2003-12-08 12:56:19
<br>内容:我已经注册了<BR>我试过,用在DALOG上添加控件的方式就不存在这种问题
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:BigJames 回复日期:2003-12-08 13:25:18
<br>内容:Licence的问题。<BR>你用在DALOG上添加控件的方式,已经把Licence信息加入到编译后的可运行程序中了。<BR>但是直接在程序中create会出问题。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:freeaward 回复日期:2003-12-08 13:31:21
<br>内容:<BLOCKQUOTE>引用“第3楼”所言<BR><Q>Licence的问题。 你用在DALOG上添加控件的方式,已经把Licence信息加入到编译后的可运行程序中了。 但是直接在程序中create会出问题。</Q></BLOCKQUOTE><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>
回复者:BigJames 回复日期:2003-12-08 13:57:07
<br>内容:找到这段代码<BR>class CCommCtrl : public CWnd<BR>{<BR>protected:<BR> DECLARE_DYNCREATE(CCommCtrl)<BR>public:<BR> CLSID const& GetClsid()<BR> {<BR> static CLSID const clsid<BR> = { 0x648a5600, 0x2c6e, 0x101b, { 0x82, 0xb6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x14 } };<BR> return clsid;<BR> }<BR><BR> virtual BOOL Create(LPCTSTR /*lpszClassName*/,<BR> LPCTSTR lpszWindowName, DWORD dwStyle,<BR> const RECT& rect,<BR> CWnd* pParentWnd, UINT nID,<BR> CCreateContext* /*pContext = NULL*/)<BR> { <BR> return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); <BR> }<BR><BR> BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,<BR> const RECT& rect, CWnd* pParentWnd, UINT nID,<BR> CFile* pPersist = NULL, BOOL bStorage = FALSE,<BR> BSTR bstrLicKey = NULL)<BR> { <BR> return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID, pPersist, bStorage, bstrLicKey); <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>
回复者:BigJames 回复日期:2003-12-08 13:59:42
<br>内容:修改一下后面那个Create,如下<BR>BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,<BR> const RECT& rect, CWnd* pParentWnd, UINT nID,<BR> CFile* pPersist = NULL, BOOL bStorage = FALSE,<BR> BSTR bstrLicKey = NULL)<BR>{ <BR> CString stra = "Copyright (c) 1998 Microsoft corp."; //随便写,只要不是空,就行。<BR> return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID, pPersist, bStorage, stra.AllocSysString()); <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>
回复者:freeaward 回复日期:2003-12-08 14:22:07
<br>内容:不行,连在安装了VC的计算机上也不行了
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:BigJames 回复日期:2003-12-08 15:05:08
<br>内容:那你找一下和CCommCtrl有关的lic文件,把他拷到目标机器上和ocx放在一起。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:freeaward 回复日期:2003-12-08 15:27:51
<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>
回复者:freeaward 回复日期:2003-12-08 15:56:04
<br>内容:我将文件传上来,能不能帮我分析一下是哪的问题?我打包的文件有:MSCOMM32.OCX,<BR>MFC42.DLL,MFC42D.DLL,MFCO42D.DLL,MSVCRT.DLLMSVCRTD.DLL;是不是还有DLL文件需要安装。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:BigJames 回复日期:2003-12-08 16:22:08
<br>内容:看一下附件,修改一下,我这里没有没有装VC的机器。本地我已经侧过了,Create成功。自己测一下没有装VC的机器
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:BigJames 回复日期:2003-12-08 16:23:13
<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>
回复者:freeaward 回复日期:2003-12-08 16:23:21
<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>回复者:BigJames 回复日期:2003-12-08 16:27:06
<br>内容:或者,不用修改CCommctrl的文件,做法如下:<BR><BR>=========================================<BR>Edit the MainFrm.cpp file:<BR>Add the following include file after the existing #include line for MainFrm.h:<BR>#include "CMSComm.h"<BR> <BR>Add the declaration for pwchLicenseKey[], which you placed on the Clipboard earlier by using the License Key Requester tool:<BR>/*<BR>Copyright (c) 1994 <BR>*/ <BR><BR>WCHAR pwchLicenseKey[] =<BR>{<BR> 0x0043, 0x006F, 0x0070, 0x0079, 0x0072, 0x0069, <BR> 0x0067, 0x0068, 0x0074, 0x0020, 0x0028, 0x0063, <BR> 0x0029, 0x0020, 0x0031, 0x0039, 0x0039, 0x0034, <BR> 0x0020<BR>};<BR> <BR>Add the following code to the end of the CMainFrame::OnCreate method just before the final return statement. This code creates an instance of the CMSComm class by using the run-time license data that is found in pwchLicenseKey. This example only tests to determine if creation is possible, and then displays a diagnostic message.<BR>// Create the license string<BR>BSTR bStrLicense = ::SysAllocStringLen(pwchLicenseKey,<BR> sizeof(pwchLicenseKey)/sizeof(WCHAR));<BR> <BR>// Create the CMSComm object with run-time license data<BR>CMSComm * pComm = new CMSComm; <BR>pComm->Create(NULL, WS_VISIBLE, CRect(0,0,0,0), <BR> this, 999, NULL, FALSE, bStrLicense);<BR> <BR>// Release the memory for license string<BR>::SysFreeString(bStrLicense);<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>
回复者:freeaward 回复日期:2003-12-08 16:35:29
<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 + -