社区
C++ Builder
帖子详情
How to build the relation of one Extention name? (just like *.txt->Notepad)?
dycdyc123
2001-06-28 08:01:34
加精
...全文
97
10
打赏
收藏
How to build the relation of one Extention name? (just like *.txt->Notepad)?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
10 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
smartboyme
2001-06-28
打赏
举报
回复
这样的做法比较复杂点,但是我觉得可能比较好!
其实最简单的就是修改HKEY_CLASSES_ROOT\txtfile\shell\open\command下的项了
当然是针对.txt文件了。
dycdyc123
2001-06-28
打赏
举报
回复
OK!
Thanks!
smartboyme
2001-06-28
打赏
举报
回复
//这是VC下的设置open with .exe txt的代码,就是直接对注册表进行操作,是sdk的,
//你可以参考一下。要忙点别的事,我没有时间为你改写,抱歉!
BOOL StdEnableShellOpen( UINT uExtension, UINT uAppName)
{
TCHAR szExtension[EXT_MAX]="";
TCHAR szSubKey[CCH_MAX]="";
TCHAR szKeyValue[CCH_MAX]="";
TCHAR szAppFullName[CCH_MAX]="";
TCHAR szAppName[CCH_MAX]="";
TCHAR szFileKey[CCH_MAX]="";
HKEY hKey;
DWORD dw;
LoadString(g_hInstance,uExtension,szExtension,sizeof(szExtension));
ZeroMemory(szSubKey,sizeof(szSubKey));
*szSubKey='.';
lstrcat(szSubKey,szExtension);
hKey=StdRegCreateKey(HKEY_CLASSES_ROOT,szSubKey,&dw);
RETURN_0_IF_0(hKey);
if (REG_OPENED_EXISTING_KEY==dw)
{
StdRegReadString(hKey,NULL,szKeyValue);
}
else
{
ZeroMemory(szKeyValue,sizeof(szKeyValue));
lstrcpy(szKeyValue,szExtension);
lstrcat(szKeyValue,"file");
lstrcpy(szFileKey,szKeyValue);
StdRegWriteString(hKey,NULL,szKeyValue);
}
RegCloseKey(hKey);
lstrcpy(szKeyValue,"txtfile");
ZeroMemory(szSubKey,sizeof(szSubKey));
lstrcpy(szSubKey,szKeyValue);
hKey=StdRegCreateKey(HKEY_CLASSES_ROOT,szSubKey,&dw);
RETURN_0_IF_0(hKey);
RegCloseKey(hKey);
StdGetAppFullName(szAppFullName);
lstrcat(szSubKey,"\\DefaultIcon");
hKey=StdRegCreateKey(HKEY_CLASSES_ROOT,szSubKey,&dw);
RETURN_0_IF_0(hKey);
if (REG_CREATED_NEW_KEY==dw)
{
lstrcpy(szKeyValue,szAppFullName);
lstrcat(szKeyValue,",0");
StdRegWriteString(hKey,NULL,szKeyValue);
}
RegCloseKey(hKey);
lstrcpy(szSubKey,szKeyValue);
lstrcat(szSubKey,"\\Shell");
hKey=StdRegCreateKey(HKEY_CLASSES_ROOT,szSubKey,&dw);
RETURN_0_IF_0(hKey);
ZeroMemory(szKeyValue,sizeof(szKeyValue));
if (REG_OPENED_EXISTING_KEY==dw)
{
StdRegReadString(hKey,NULL,szKeyValue);
}
if ('\0'==*szKeyValue)
{
lstrcpy(szKeyValue,"Open_with");
LoadString(g_hInstance,uAppName,szAppName,sizeof(szAppName));
lstrcat(szKeyValue,szAppName);
StdRegWriteString(hKey,NULL,szKeyValue);
}
RegCloseKey(hKey);
lstrcat(szSubKey,"\\");
lstrcat(szSubKey,szKeyValue);
lstrcat(szSubKey,"\\Command");
hKey=StdRegCreateKey(HKEY_CLASSES_ROOT,szSubKey,&dw);
RETURN_0_IF_0(hKey);
lstrcpy(szKeyValue,szAppFullName);
lstrcat(szKeyValue," %1");
StdRegWriteString(hKey,NULL,szKeyValue);
RegCloseKey(hKey);
return TRUE;
}
wjzhuang
2001-06-28
打赏
举报
回复
两种方法:
1.修改注册表(可惜我不知道在那里修改)
2.把原来的程序覆盖掉,比如写一个notepad覆盖windows自带的notepad
cabbagebai
2001-06-28
打赏
举报
回复
什么叫设置文件的默认打开程序?
用BCB不是直接在你自己的程序中打开吗?
dycdyc123
2001-06-28
打赏
举报
回复
我想他是要问怎么设置文件的默认打开程序!
Yes!
How to realize with bcb??
smartboyme
2001-06-28
打赏
举报
回复
我想他是要问怎么设置文件的默认打开程序!
wjzhuang
2001-06-28
打赏
举报
回复
问题太模糊,不太明白!
dycdyc123
2001-06-28
打赏
举报
回复
smartboyme(小东): Are you mailed ????(@~@)
How to realize with BCB???
smartboyme
2001-06-28
打赏
举报
回复
写注册表啊!
JAVA_API1.6文档(中文)
javax.management.
relation
提供
Relation
Service 的定义。 javax.management.remote 对 JMX MBean 服务器进行远程访问使用的接口。 javax.management.remote.rmi RMI 连接器是供 JMX Remote API 使用的一种连接...
Yii的CDbCriteria查询(以及使用$criteria->join出现问题的解决方法)
Yii的CDbCriteria查询(以及使用$criteria->join出现问题的解决方法) $criteria = new CDbCriteria; //select $criteria->select = '*'; //默认* $criteria->select = 'id,name';
最全坑和问题总结|升级spring-boot->2.6.2|hiberate->5.4.33.Final|spring cloud->2021.0.0 |spring admin->2.4.1
The dependencies of some of the beans in the application context form a cycle Description: The dependencies of some of the beans in the application context form a cycle: userController (field ...
python-docx操作word文件(*.docx)
# This gets access to the document.xml.rels file and gets a new
relation
id value part = paragraph.part r_id = part.relate_to(url, docx.opc.constants.
RELATION
SHIP_TYPE.HYPERLINK, is_external=True) ...
[渝粤题库] 国家开放大学 人文英语4 资料
The sender’s personality, beliefs, cultural and educational background all influence the message and it is important for the sender to be aware of this as he or she is encoding the message....
C++ Builder
13,826
社区成员
102,678
社区内容
发帖
与我相关
我的任务
C++ Builder
C++ Builder相关内容讨论区
复制链接
扫一扫
分享
社区描述
C++ Builder相关内容讨论区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章