请各位老师指点,怎样关联“.EXE”文件?

chary8088 2004-06-09 07:17:26
也就是当“EXE”文件启动时,我的程序也同时启动;我不是搞病毒啊
我这样作的为什么不行?
CString str;
str.Format("%s",AfxGetApp()->m_lpCmdLine);
const char*MutexObject="Mysvchost";
hMutex=NULL;
hMutex=::CreateMutex(false,false,MutexObject);
if(hMutex!=NULL)
{
DWORD err=GetLastError();
if(err==ERROR_ALREADY_EXISTS)::PostQuitMessage(0);
}
if(str!="")
{
CString temp;
char ch;
int length=str.GetLength();
for(int i=0;i<length;i++)
{
ch=str.GetAt(i);
if(ch=='\\')
temp=temp+ch;
}

temp=temp.Left(temp.GetLength()-2);
temp=temp.Mid(1);
char str1[]="\"%1\"%*";
::RegSetValue(HKEY_CLASSES_ROOT,"exefile\\shell\\open\\command",
REG_SZ,(LPCTSTR)str1,strlen(str1)+1);
ShellExecute(NULL,"open",temp,NULL,NULL,SW_HIDE);
}
TCHAR str2[256];
GetModuleFileName(NULL,str2,255);
strcat(str2,"\"%1\"%*");
::RegSetValue(HKEY_CLASSES_ROOT,"exefile\\shell\\open\\command",

REG_SZ,(LPCTSTR)str2,strlen(str2)+1);
...全文
87 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
code2004 2004-08-27
  • 打赏
  • 举报
回复
在资源管理器中用右键点击你要打开的文件,在出现的弹出菜单中选择用哪一种软件打开,出现关联对话框,选中复选框永久关联该程序点击确定。
凤凰 2004-08-27
  • 打赏
  • 举报
回复
更改和exe的关联
  • 打赏
  • 举报
回复
这个你该到程序设计板块问吧
chary8088 2004-06-09
  • 打赏
  • 举报
回复
上面的代码哪点错了啊,请老师指点啊?
icuc88 2004-06-09
  • 打赏
  • 举报
回复
@@,看错了,呵呵
icuc88 2004-06-09
  • 打赏
  • 举报
回复
assoc .exe=EXEFILE

6,871

社区成员

发帖
与我相关
我的任务
社区描述
Windows 2016/2012/2008/2003/2000/NT
社区管理员
  • Windows Server社区
  • qishine
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧