| |

VerySource

 Forgot password?
 Register
Search
View: 2273|Reply: 13

Can I run the program directly in C?

[Copy link]

2

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-5 12:10:01
| Show all posts |Read mode
For example, my U disk, I copy QQ to the Tencent directory of the U disk, and then I want to write an autorun.exe file in C language, when running this file, Tencent\qq.exe will be run, and in order to use it on different machines I require the use of relative directories. How can I achieve this? Thank you !!!!
Reply

Use magic Report

0

Threads

14

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 Hong Kong

Post time: 2020-1-5 19:06:01
| Show all posts
ShellExecute
Or CreateProcess
As for the directory problem, the absolute directory and the relative directory are the same. If the program and the Tencent directory are located in the same directory, the path .\Tencent\qq.exe can be used. As for the program on the u disk or the hard disk, it is the same.
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-1-9 18:00:02
| Show all posts
Command line: start (parameter setting, see start /?) "Tencent\qq.exe"
c: system ("start ...");
Of course the upstairs is more formal
Reply

Use magic Report

0

Threads

63

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-1-10 14:09:01
| Show all posts
system ("C:\\...\\qq.exe");
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Brazil

Post time: 2020-1-17 16:54:01
| Show all posts
Studying ~~~
Reply

Use magic Report

2

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 United States

 Author| Post time: 2020-1-19 03:54:01
| Show all posts
I don't know too much, can you give me a code, QQ is in the Tencent directory in the root directory of the USB flash drive, that is, the path of QQ is X:\Tencent\QQ.exe, and autorun.exe is in the root directory of the USB flash drive. How can I write it in C? Thank you , Preferably TC2.0.
Reply

Use magic Report

0

Threads

14

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 Thailand

Post time: 2020-1-19 18:45:02
| Show all posts
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
HINSTANCE result = ShellExecute (NULL, _T ("open"), _T (".\Tencent\qq.exe"), NULL, NULL, SW_SHOW);
return 0;
}
There is no tc on hand, this is under vc.
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-19 21:36:01
| Show all posts
Simply look for the mobile storage device first, and then go to the root directory of this device to find QQ.exe recursively, and then find CreateProcess (), or WinExec ().
Of course, first of all, that machine needs to support your USB flash drive, can detect the plug-in status of your USB flash drive, and then, hey, it is not easy to detect the status of a certain storage device.
Reply

Use magic Report

0

Threads

5

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-20 10:54:01
| Show all posts
Is C ???
I don't know, MFC can call the dos command with ShellExecute or cmd.
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-1-20 14:18:01
| Show all posts
system ()
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