vb 控件注册和反注册有关问题
vb 控件注册和反注册问题
在启动我的软件时 控件注册判断:
因为电脑中有可能有其他软件安装的控件名称跟我的软件控件名称一样 或者是版本不一样导致我的软件不能正常运行,所以我想在启动我的软件前 先卸载到电脑中跟我软件同名的控件 然后我在注册我自己的控件。
‘1卸载电脑中已经存在的控件
(regsvr32/u) 如果有相同的控件就卸载注册 但是关键不知道具体路径,有什么方式在不知道路径位置的情况下也能卸载
'2注册我程序目录下的控件
'载入窗体前注册控件
On Error Resume Next
ShellExecute 0, "Open", "regsvr32", "bin\xxx.OCX /s", "", SW_SHOWNORMAL
DoEvents
------解决方案--------------------
没必要,因为GUID几乎不可能重复。
CoCreateGuid
Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
HRESULT CoCreateGuid(
GUID *pguid //Pointer to the GUID on return
);
Parameter
pguid
[out] Pointer to the requested GUID on return.
Return Value
S_OK
The GUID was successfully created.
Win32 errors are returned byUuidCreate but wrapped as an HRESULT.
Remarks
The CoCreateGuid function calls the RPC function UuidCreate, which creates a GUID, a globally unique 128-bit integer. Use the CoCreateGuid function when you need an absolutely unique number that you will use as a persistent identifier in a distributed environment.To a very high degree of certainty, this function returns a unique value – no other invocation, on the same or any other system (networked or not), should return the same value.
QuickInfo
Windows NT: Use version 3.1 or later.
Windows: Use Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in objbase.h.
Import Library: Included as a resource in ole32.dll.
See Also
UuidCreate
------解决方案--------------------
GUID不可能重复。不过lz的做法太猥琐了
在启动我的软件时 控件注册判断:
因为电脑中有可能有其他软件安装的控件名称跟我的软件控件名称一样 或者是版本不一样导致我的软件不能正常运行,所以我想在启动我的软件前 先卸载到电脑中跟我软件同名的控件 然后我在注册我自己的控件。
‘1卸载电脑中已经存在的控件
(regsvr32/u) 如果有相同的控件就卸载注册 但是关键不知道具体路径,有什么方式在不知道路径位置的情况下也能卸载
'2注册我程序目录下的控件
'载入窗体前注册控件
On Error Resume Next
ShellExecute 0, "Open", "regsvr32", "bin\xxx.OCX /s", "", SW_SHOWNORMAL
DoEvents
------解决方案--------------------
没必要,因为GUID几乎不可能重复。
CoCreateGuid
Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
HRESULT CoCreateGuid(
GUID *pguid //Pointer to the GUID on return
);
Parameter
pguid
[out] Pointer to the requested GUID on return.
Return Value
S_OK
The GUID was successfully created.
Win32 errors are returned byUuidCreate but wrapped as an HRESULT.
Remarks
The CoCreateGuid function calls the RPC function UuidCreate, which creates a GUID, a globally unique 128-bit integer. Use the CoCreateGuid function when you need an absolutely unique number that you will use as a persistent identifier in a distributed environment.To a very high degree of certainty, this function returns a unique value – no other invocation, on the same or any other system (networked or not), should return the same value.
QuickInfo
Windows NT: Use version 3.1 or later.
Windows: Use Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in objbase.h.
Import Library: Included as a resource in ole32.dll.
See Also
UuidCreate
------解决方案--------------------
GUID不可能重复。不过lz的做法太猥琐了