控件注册

一般注册控件的时候,如果控件所在路径中有空格的最好使用短路径 。如果使用长路径一般会注册失败。

C:/Documents and Settings/Administrator/桌面/远程控制台/远程控制台/UNICOWS.DLL

短路径为

C:/DOCUME~1/ADMINI~1/桌面/远程控~1/远程控~1/UNICOWS.DLL

 

DWORD GetShortPathName(
  LPCTSTR lpszLongPath,
  LPTSTR lpszShortPath,
  DWORD cchBuffer
);
Parameters
lpszLongPath
[in] Pointer to a null-terminated path string. The function retrieves the short form of this path.

In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "//?/" to the path. For more information, see Naming a File.

Windows Me/98/95:  This string must not exceed MAX_PATH characters.
lpszShortPath
[out] Pointer to a buffer to receive the null-terminated short form of the path specified by lpszLongPath.
cchBuffer
[in] Size of the buffer pointed to by lpszShortPath, in TCHARs.
Return Values

If the function succeeds, the return value is the length, in TCHARs, of the string copied to lpszShortPath, not including the terminating null character.

If the lpszShortPath buffer is too small to contain the path, the return value is the size of the buffer, in TCHARs, required to hold the path. Therefore, if the return value is greater than cchBuffer, call the function again with a buffer that is large enough to hold the path.

If the function fails for any other reason, the return value is zero. To get extended error information, call GetLastError.

//注册控件

void TestDlg::OnBnClickedButton1(CString strShortName )
{

 CString strReg="regsvr32.exe " ;
 CString strPath="/s "+strShortName;

 ShellExecute(NULL,"OPEN",strReg,strPath,NULL,SW_HIDE);
 //return   bResult   ;  
}

//注意/s是为了在注册时不显示注册对话框

 

//卸载控件

void TestDlg::OnBnClickedButton2(CString strShortName )
{

 CString strReg="regsvr32.exe " ;
 CString strPath="/u/s "+strShortName;

 ShellExecute(NULL,"OPEN",strReg,strPath,NULL,SW_HIDE);
 //return   bResult   ;  
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值