怎样让程序在windows启动时自动运行~~~? 写注册表RegtoStartup();自动会把把本程序添加到run子键。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 需要设置注册表,可以留个E-Mail吗下次上网时给你发 int ret;HKEY hKEY; LPCTSTR Rgspath="Software\\Microsoft\\Windows\\CurrentVersion\\Run"; LPCTSTR copyto="c:\\WINNT\\system32\\名字.exe"; //你的程序名称 ret=RegOpenKeyEx(HKEY_LOCAL_MACHINE,Rgspath,0,KEY_WRITE, &hKEY); RegDeleteValue(hKEY,"名字"); RegSetValueEx(hKEY,"名字",0,REG_EXPAND_SZ,(unsigned char*)copyto,MAX_STR); RegtoStartup(){HKEY hKey; char szPath[200]; GetExePath(szPath); strcat(szPath, "\\XXX.exe"); unsigned long nSize = strlen(szPath); if(RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &hKey)!=ERROR_SUCCESS) { return; } if(RegSetValueEx(hKey,"XXX", 0, REG_SZ, (unsigned char *)szPath, nSize) != ERROR_SUCCESS) { RegCloseKey(hKey); } RegCloseKey(hKey); if(!bIsNT) { if(RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunServices", &hKey)!=ERROR_SUCCESS) { return; } if(RegSetValueEx(hKey,"XXX", 0, REG_SZ, (unsigned char *)szPath, nSize) != ERROR_SUCCESS) { RegCloseKey(hKey); } RegCloseKey(hKey); } return;} windows98下自动启动程序的10种方法 1. Autostart 文件 C:\windows\start menu\programs\startup {chinese/english} C:\windows\Menu D閙arrer\Programmes\D閙arrage {french} 在注册表中的位置: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders Startup="C:\windows\start menu\programs\startup" 所以它将很容易被程序更改 2. Win.ini [windows] load=file.exe run=file.exe 3. System.ini [boot] Shell=Explorer.exe file.exe 4. c:\windows\winstart.bat 看似平常,但每次都重新启动 5. Registry键 [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices] [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce] [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run] [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce] [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run] [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce] [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices] 6. c:\windows\wininit.ini 一旦运行就被windows删除,安装的setup程序常用 Example: (content of wininit.ini) [Rename] NUL=c:\windows\picture.exe 例子:将c:\windows\picture.exe设置为NUL, 表示删除它,完全隐蔽的执行! 7. Autoexec.bat 在DOS下每次自启动 8. Registry Shell Spawning (使用过Subseven吗?看看吧) [HKEY_CLASSES_ROOT\exefile\shell\open\command] @="\"%1\" %*" [HKEY_CLASSES_ROOT\comfile\shell\open\command] @="\"%1\" %*" [HKEY_CLASSES_ROOT\batfile\shell\open\command] @="\"%1\" %*" [HKEY_CLASSES_ROOT\htafile\Shell\Open\Command] @="\"%1\" %*" [HKEY_CLASSES_ROOT\piffile\shell\open\command] @="\"%1\" %*" [HKEY_LOCAL_MACHINE\Software\CLASSES\batfile\shell\open\command] @="\"%1\" %*" [HKEY_LOCAL_MACHINE\Software\CLASSES\comfile\shell\open\command] @="\"%1\" %*" [HKEY_LOCAL_MACHINE\Software\CLASSES\exefile\shell\open\command] @="\"%1\" %*" [HKEY_LOCAL_MACHINE\Software\CLASSES\htafile\Shell\Open\Command] @="\"%1\" %*" [HKEY_LOCAL_MACHINE\Software\CLASSES\piffile\shell\open\command] @="\"%1\" %*" 这些"%1 %*"需要被赋值, 如果将其改为 "server.exe %1 %*", server.exe将在每次启动时被执行,这些exe/pif/com/bat/hta等文件都可被执行 9. Icq Inet [HKEY_CURRENT_USER\Software\Mirabilis\ICQ\Agent\Apps\test] "Path"="test.exe" "Startup"="c:\\test" "Parameters"="" "Enable"="Yes" [HKEY_CURRENT_USER\Software\Mirabilis\ICQ\Agent\Apps\ 当icq发现网络连接时,将被执行(我使用的icq2000b的键值有所不同,但您可以自行查找) 您发现OICQ有这方面的问题吗?^_^... 9. 杂项说明 找找以下的键值: [HKEY_LOCAL_MACHINE\Software\CLASSES\ShellScrap] @="Scrap object" "NeverShowExt"="" NeverShowExt 键 可以隐藏SHS文件的扩展名.shs 如果你将一个文件改名为:"abc.jpg.shs" 它只显示"abc.jpg" 如果你的注册表里有很多NeverShowExt键值,删除他们。 注意: 这些方法不能全部适应Win2K,但您可以自行检测。 告诉我你的e-mail:我发给你一个程序!嘿嘿!!!! 怎么在一个对话框程序的picture控件中绘图? 编译时提示关于stdafx.h文件的warning,请各位指教一下 菜鸟请教VC 关于字符编码的问题 VC 怎样与WebServer通信? 这个链接错误怎么解决? 急............关于CRecordset 帮帮忙: 请问五一放假是几号到几号啊 dll中如何调用_stdcall修饰的函数 请问各位大哥:AfxBeginThread函数第一个参数怎么传递?(非CWinThread继承版) 网上有(深入浅出mfc)这本书可以下载吗?? 怎么才能知道,DLL文件的,COM组件是否已经注册 "
可以留个E-Mail吗
下次上网时给你发
HKEY hKEY;
LPCTSTR Rgspath="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
LPCTSTR copyto="c:\\WINNT\\system32\\名字.exe"; //你的程序名称
ret=RegOpenKeyEx(HKEY_LOCAL_MACHINE,Rgspath,0,KEY_WRITE, &hKEY);
RegDeleteValue(hKEY,"名字");
RegSetValueEx(hKEY,"名字",0,REG_EXPAND_SZ,(unsigned char*)copyto,MAX_STR);
{HKEY hKey;
char szPath[200];
GetExePath(szPath);
strcat(szPath, "\\XXX.exe");
unsigned long nSize = strlen(szPath); if(RegOpenKey(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
&hKey)!=ERROR_SUCCESS)
{
return;
}
if(RegSetValueEx(hKey,"XXX", 0, REG_SZ, (unsigned char *)szPath, nSize) != ERROR_SUCCESS)
{
RegCloseKey(hKey);
}
RegCloseKey(hKey); if(!bIsNT)
{
if(RegOpenKey(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunServices",
&hKey)!=ERROR_SUCCESS)
{
return;
}
if(RegSetValueEx(hKey,"XXX", 0, REG_SZ, (unsigned char *)szPath, nSize) != ERROR_SUCCESS)
{
RegCloseKey(hKey);
}
RegCloseKey(hKey);
}
return;}
C:\windows\start menu\programs\startup {chinese/english}
C:\windows\Menu D閙arrer\Programmes\D閙arrage {french}
在注册表中的位置: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
Folders Startup="C:\windows\start menu\programs\startup"
所以它将很容易被程序更改 2. Win.ini
[windows]
load=file.exe
run=file.exe 3. System.ini [boot]
Shell=Explorer.exe file.exe 4. c:\windows\winstart.bat
看似平常,但每次都重新启动 5. Registry键
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run]
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices] 6. c:\windows\wininit.ini
一旦运行就被windows删除,安装的setup程序常用
Example: (content of wininit.ini)
[Rename]
NUL=c:\windows\picture.exe
例子:将c:\windows\picture.exe设置为NUL, 表示删除它,完全隐蔽的执行! 7. Autoexec.bat
在DOS下每次自启动 8. Registry Shell Spawning (使用过Subseven吗?看看吧)
[HKEY_CLASSES_ROOT\exefile\shell\open\command] @="\"%1\" %*"
[HKEY_CLASSES_ROOT\comfile\shell\open\command] @="\"%1\" %*"
[HKEY_CLASSES_ROOT\batfile\shell\open\command] @="\"%1\" %*"
[HKEY_CLASSES_ROOT\htafile\Shell\Open\Command] @="\"%1\" %*"
[HKEY_CLASSES_ROOT\piffile\shell\open\command] @="\"%1\" %*"
[HKEY_LOCAL_MACHINE\Software\CLASSES\batfile\shell\open\command] @="\"%1\" %*"
[HKEY_LOCAL_MACHINE\Software\CLASSES\comfile\shell\open\command] @="\"%1\" %*"
[HKEY_LOCAL_MACHINE\Software\CLASSES\exefile\shell\open\command] @="\"%1\" %*"
[HKEY_LOCAL_MACHINE\Software\CLASSES\htafile\Shell\Open\Command] @="\"%1\" %*"
[HKEY_LOCAL_MACHINE\Software\CLASSES\piffile\shell\open\command] @="\"%1\" %*" 这些"%1 %*"需要被赋值, 如果将其改为 "server.exe %1 %*",
server.exe将在每次启动时被执行,这些exe/pif/com/bat/hta等文件都可被执行 9. Icq Inet
[HKEY_CURRENT_USER\Software\Mirabilis\ICQ\Agent\Apps\test]
"Path"="test.exe"
"Startup"="c:\\test"
"Parameters"=""
"Enable"="Yes" [HKEY_CURRENT_USER\Software\Mirabilis\ICQ\Agent\Apps\
当icq发现网络连接时,将被执行(我使用的icq2000b的键值有所不同,但您可以自行查找)
您发现OICQ有这方面的问题吗?^_^... 9. 杂项说明
找找以下的键值:
[HKEY_LOCAL_MACHINE\Software\CLASSES\ShellScrap]
@="Scrap object" "NeverShowExt"="" NeverShowExt 键 可以隐藏SHS文件的扩展名.shs
如果你将一个文件改名为:"abc.jpg.shs" 它只显示"abc.jpg"
如果你的注册表里有很多NeverShowExt键值,删除他们。
注意:
这些方法不能全部适应Win2K,但您可以自行检测。
嘿嘿!!!!