| |

VerySource

 Forgot password?
 Register
Search
View: 786|Reply: 7

How to add programs to windows startup items?

[Copy link]

2

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-10-12 11:00:01
| Show all posts |Read mode
How to add the program to the windows startup item? That is, the boot program starts automatically. Please support~~
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-10-12 12:30:01
| Show all posts
Startup items in the start menu, registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, etc.
Reply

Use magic Report

0

Threads

20

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-10-12 12:45:01
| Show all posts
CString StrFilter="Executable files (*.exe)|*.exe|All files (*.*)|*.*||";
CFileDialog Dlg(TRUE,NULL,NULL,NULL,StrFilter,this);
if(Dlg.DoModal()==IDCANCEL)
return;
HKEY hKey;
LPCTSTR StrKey="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
if(ERROR_SUCCESS==::RegOpenKeyEx(HKEY_CURRENT_USER,StrKey,NULL,KEY_ALL_ACCESS,&hKey))
{
CString Value=Dlg.GetPathName();
LPCSTR KeyValue=Dlg.GetFileTitle();
if(ERROR_SUCCESS==::RegSetValueEx(hKey,(LPCTSTR)KeyValue,0,REG_SZ,
(BYTE *)(LPCSTR)Value,strlen(Value)+1))
{
AfxMessageBox("Set the program to run automatically when the system starts!");
}
//::RegDeleteValue(hKey,(LPCTSTR)KeyValue);
::RegCloseKey(hKey);
}
Reply

Use magic Report

1

Threads

12

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-10-12 14:45:02
| Show all posts
Join the registration form!
Reply

Use magic Report

2

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-10-12 15:30:01
| Show all posts
.... I want to add it to the reg directly when the MFC program is initialized, instead of adding another .exe program

   How should this be done?
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-10-12 16:00:01
| Show all posts
TCHAR chPath[MAX_PATH + 1];
GetModuleFileName(NULL, chPath, MAX_PATH);
HKEY hKey;
LPCTSTR StrKey="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
if(ERROR_SUCCESS==::RegOpenKeyEx(HKEY_CURRENT_USER,StrKey,NULL,KEY_ALL_ACCESS,&hKey))
{
CString Value=chPath
if(ERROR_SUCCESS==::RegSetValueEx(hKey,(LPCTSTR)KeyValue,0,REG_SZ,
(BYTE *)(LPCSTR)Value,strlen(Value)+1))
{
AfxMessageBox("Set the program to run automatically when the system starts!");
}
::RegCloseKey(hKey);
}
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-10-12 16:30:01
| Show all posts
TCHAR chPath[MAX_PATH + 1];
GetModuleFileName(NULL, chPath, MAX_PATH);
HKEY hKey;
LPCTSTR StrKey="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
LPCTSTR KeyValue="Turn on";
if(ERROR_SUCCESS==::RegOpenKeyEx(HKEY_CURRENT_USER,StrKey,NULL,KEY_ALL_ACCESS,&hKey))
{
CString Value=chPath;
if(ERROR_SUCCESS==::RegSetValueEx(hKey,(LPCTSTR)KeyValue,0,REG_SZ,
(BYTE *)(LPCSTR)Value,strlen(Value)+1))
{
::MessageBox(NULL,"ok!","Boot",MB_TOPMOST);
}
::RegCloseKey(hKey);
}
Reply

Use magic Report

2

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-10-12 19:45:01
| Show all posts
Thanks very much~!!!!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list