Answer the question
In order to leave comments, you need to log in
How to programmatically create a shortcut in MS VC++ 14.0 Windows 10?
I'm into sports programming. Now I decided to try myself a little differently, and immediately ran into a problem: Let's say I have a program in the root of the drive D:\app1.exe , on the same drive there is a folder with another program D:\test\example.exe . So: during my work, the app1.exe program calls the program in the test folder along the path .\test\example.exe ( because app1.exe is located in the root D:\, then this is the same as D :\test\example.exe ). The example.exe program as a result of its work creates an output data file, for example, output.txt; The problem is that when you run app1.exe , which in turn runs example.exe , and this program creates an output.txt file , then the output.txt file is created at the root of D:\ , and not in the folder where the program is located , which creates the file (should be in D:\test\ ). Found out that when you run the program example.exethrough the shortcut everything is created as it should. I searched on the Internet how to programmatically create shortcuts on MS VC ++ (namely, programmatically, in no way manually), but after running the code, only a file with hieroglyphs in the name appears. Please help me find the code that will work. Preferably with a description. Or maybe you know another way to achieve the desired result? Thanks in advance.
Windows 10 Home
MS VC++ 14.0
C++11
Answer the question
In order to leave comments, you need to log in
blah blah blahWhen you run the program, its environment contains the full path. Take the program folder and create your output.txt there.
Модуль: opera.exe, 32-битный
Полный путь: C:\Program Files (x86)\Opera\41.0.2353.69\opera.exe
Версия файла: 41.0.2353.69
Описание: Opera Internet Browser
PID: 9892
Parent PID: 9884
Приоритет: 8
Нитей: 36
Владелец: TSK-HOME\tsk (S-1-5-21-2854898707-2914625786-2582272332-1001)
Сеанс: 1
In fact, in this century, for the creation of files by the program in the same folder where the program is located, they hit the fingers with a rail.
Because even the "windowsills" have already realized that the folder from where something is launched should not be available to anyone on the record.
The default program should only be allowed to create any files in the path %APPDATA%/(name of this program)/.
Well, maybe ask the user where he prefers to save this file.
And dumping files under your own feet is the stone age of IT, and it is this inability and unwillingness to organize a safe space that is the reason that viruses walk in herds across Windows.
Your method with a label is nothing more than a miserable crutch.
Consolidate everything to one file.
Let app1.exe immediately create output.txt in D:/test
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question