可不可以在CBC中通过代码注册MSCOMM32.ocx相关信息
MSCOMM32.ocx 有版权串要写到注册表中,
注册表中新建一个主键项:HKEY_CLASSES_ROOT\Licenses,在其中添加主键
4250E830-6AC2-11cf-8ADB-00AA00C00905 并将内容设置为:
kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun
[解决办法]
RootKey是注册表的根键值,比如运行regedit后看到的HKEY_USERS,HKEY_LOCAL_MACHINE就是RootKey,在TRegIniFile中缺省的RootKey
是HKEY_USERS.
下面的例子是TRegistry的,TRegIniFile也差不多
void __fastcall TfrmMainForm::WriteToMyRegistry(int table_count)
{
//TODO: Add your source code here
TRegistry *MyRegistry=new TRegistry;
MyRegistry->RootKey=HKEY_LOCAL_MACHINE;
//改变缺省Rootkey
if(!MyRegistry->OpenKey("Software\\Microsoft\\Windows\\Current\
Version\\Run",true)) //打开主键
//这样双引号里面的东西就变成了CurrentKey
{
Application->MessageBox("注册表内容无效",
"读取注册表出错",MB_ICONERROR);
MyRegistry->CloseKey();
delete MyRegistry;
return;
}
MyRegistry->WriteString("myrun","c:\\sthvcd\\sthvcd.exe");
MyRegistry->CloseKey();
delete MyRegistry;
[解决办法]
简单写几行代码就搞定了:
#include <registry.hpp>void __fastcall TForm1::Button1Click(TObject *Sender){ TRegistry *reg = new TRegistry; reg->RootKey = HKEY_CLASSES_ROOT; reg->OpenKey("Licenses\\4250E830-6AC2-11cf-8ADB-00AA00C00905", true); reg->WriteString("", "kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun"); reg->CloseKey(); delete reg;}