How can I get set input files path runtime? - c++

I need to select the path directory of my "files.dat" at runtime.
My Visual Studio project create a .dll (that is a Nutech plugin) and in the code it is just implemented a load functions of this files. So I need that the user can choose the directory of files to load to the process.

Your function must receive a name of an input file as a parameter and do exactly one thing: load data from the file. Everything else (like showing a dialog) is responsibility of the user code.

Related

To Determine if a .exe file is an setup file

I need to write a c/c++/kernel driver program where I can check if an .exe file is an Setup file where I can install new application in my computer (Like an .MSI file) or an normal application (For Example: If I Open an .exe file which is named as chorme.exe then it is an normal window application which only opens chrome browser , but if I Open an .exe file which is chromeinstaller.exe it is an installer which installs chrome browser in my computer).
Is there any way to determine if it's a setup file or just a application.
Microsoft itself tried to solve this with "Installer Detection" , and from their solution it becomes obvious that there is no hard solution. They look for:
Filename includes keywords like "install," "setup," "update," etc.
Keywords in the following Versioning Resource fields: Vendor, Company Name, Product Name, File Description, Original Filename, Internal Name, and Export Name.
Keywords in the side-by-side manifest embedded in the executable.
Keywords in specific StringTable entries linked in the executable.
Key attributes in the RC data linked in the executable.
Targeted sequences of bytes within the executable.
We can safely assume they're doing this because there is no ready-made solution.

Linking DKM Projects to Kernel Image(VIP) project as a Sub project/Extra Module in VxWorks Workbench4

How to Link/Load DKM projects with Kernel Image(VIP) project so that i can call the Entry point function of DKM project(application) from Kernel Image project's "usrAppInit.c" to get the application started automatically at boot time?
Could some one please describe steps or point me to any documentation?
Add the DKM project as sub-project of your VIP. You can drag and drop, or open the VIP Project Properties, and from Project References check your DKM project
In usrAppInit.c, call the entry point of your DKM. You will probably want to include the appropriate header
Modify the VIP include paths as required to include the header file.
If required, configure the kernel to use the correct build target for the DKM.
Using this approach, when you build the VIP, it will first build the child DKM projects (which will generate the .out files) then the VIP, generating a vxworks image that includes the .out files
An other solution to this problem without having the projects clubbed, Need to specify the DKM application's partial image ".o" object file path to the EXTRA_MODULES Macro rather than ".out" path. If for example the application is "myApp" , "myapp_partialImage.o" path should be specified in the Macro. Multiple paths can be specified in the Macro with the space if Multiple app needs to be linked

How do I set up this visual studio (2015) custom build step (tool?). Basically I want a pre-preprocessor step that modifies header files (c++)

I want a run a build step that looks at a .h file, adds some code based on some external params, and hands the resulting file to the preprocessor.
I see the "Custom Build Step" in the project properties. It seems to need an output file. I just want to forward the results to the preprocessor.
It seems like the custom build step wants to do a 1-time process, not per-file or by file type.
The problem is that I don't know how to send my external executable the file currently being processed (eg, "HelloWorld.cpp"). $(InputName) and %(Filename) are blank and docs say it's deprecated. How do I send the filename to my external executable?
But even if I get that working, I don't want to set this per-file. I want all header files to go through this process.
Any ideas?
I've looked at:
https://msdn.microsoft.com/en-us/library/dd293663.aspx?f=255&MSPPError=-2147217396
https://msdn.microsoft.com/en-us/library/hefydhhy(v=vs.90).aspx
https://msdn.microsoft.com/en-us/library/ff770593(v=vs.140).aspx
working on a debug, x64 config on windows.
First of all, No, you cannot modify a file and pass along the results to the next stage (that I could see). I'd need some sort of Program Transformation System.
So I need an intermediate file. That file has to be added to the project, even if it gets overwritten by your code generator. I can associate c++ header files with a custom build tool, and they will all get called one-by-one in the stage of the build specified in the Custom Build Step. The custom build tool will modify the intermediate file(s), and all is well.
The VS 2015 name for the current file being processed is %(Filename). In older versions it has been $(ProjectName) and $(InputName).

How to link file with assets under Windows

If you save any webpage under Windows, you will notice it creates a folder which is "linked" to the html file, like:
(file) Twitter.htm
(folder) Twitter_files
If you try to copy either file or folder, e.g. Twitter.htm, Twitter_files will also be copied along.
Can I achieve this functionality somehow? I am asking both as a plain Windows user and pro grammatically (e.g. a C++ API). I don't see any flag in the file properties to make them linked.

Relative path problem for a deployed win32 application

I have written a c++ program and deployed it in say c:\my_app, and my executable's path is c:\my_app\my_app.exe. Say, my_app needs many files such as the_file.txt, which is located in c:\my_app\the_file.txt.
In my executable, I open the txt file as, xx.open("the_file.txt");
Moreover, I have associated my program with let's say .myp extension.
When I'm on Desktop, and want to open a file named example.myp, my program can not see the_file.txt. Because, it (somehow) assumes that it's currently working on Desktop.
Is there any easy way to handle this problem by changing shell command for open in HKEY_CLASSES_ROOT? The naive solution would be to change all file open operations with something like %my_app_location/the_file.txt". I don't want to do that.
Always use a full path name to open a file. In other words, don't open "foo.txt", open "c:\bar\foo.txt". To find the install directory of your EXE use GetModuleFileName(), passing NULL for the module handle.
These days you shouldn't add files to c:\my_app....
Instead use the ProgramData Folder and full paths.
Use SHGetSpecialFolderPathA with CSIDL_COMMON_APPDATA to get the ProgramData folder and the create your program directory and add your files.
You should set current directory for your app's folder with SetCurrentDirectory function. After that you can open file by name without full path