I was looking at a project that someone wanted done and in order to do it I need to edit Windows' Start Up Programs. I am unsure of where to begin looking. What I really need is just a reference to some Windows API functions that will let me do this.
Thanks
Startup programs is just a directory, I don't think there are any specific functions for it. You should be able to create shortcuts inside and that should be it.
c:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\
As Nikola Smiljanić says the Startup area is just a directory with file shortcuts in it. However it is dangerous to use a hardcoded path because this changes with different versions of Windows.
You can get the path to the startup folder with the SHGetFolderPath function and CSIDL_STARTUP as a parameter.
Related
Im trying to make (what I thought was a simple) extension for Game maker studio 2.
I am restricted to making a DLL app.
I am wondering is there any was to have a dll app open the file explorer have the user locate a file and then return said directory?
I fell like this is a sumb question but one I really need to know the answer too before slaving away coding for hours only to find its not possible.
You do not want to launch the explorer but to open a file dialog that allows the user to select a file.
Depending on the framework you use in your program the solutions may differ.
If you are using Qt framework you may use a QFileDialog for a platform independent mechanism.
If you are okay that it will only works on Windows then you may directly use the WinAPI functions GetOpenFileName or GetSaveFileName (that is a lot easier than the Common Item Dialog that is suggested as replacement on their documentation pages)
On GameMaker terms, you want to use get_open_filename or get_open_filename_ext.
See Dialog Module (marketplace, github) for C++ implementation reference.
I need to make a windows console application file explorer using c++ , but I couldn't figure out how to use functions to display files nor how am I going to make it look like knowing that console application doesn't support buttons or displaying lists , specially that the project must be based on windows.h library. any tip, advice or suggestion may be helpful , thank you !
Have a look at http://www.martinbroadhurst.com/list-the-files-in-a-directory-in-c.html and scroll down to method 4. There you can see a possible implementation of a read-directory function. You should store a default start path, implement some console arguments as commands, then, whenever the user writes a command (for example goUp) ,change the path accordingly (in this case, remove the last foldername), call the function, which reads the directory, again and output all files in that folder.
BOOL WINAPI GetOpenFileName(
Inout LPOPENFILENAME lpofn
);
is used for opening a file in a VC++ program, say
C:\Hello\World\abc.txt
.
But I want to use this function to select a folder
C:\Hello\World
instaed of a file in it.
I guess I need to make some changes to the members of the structure "OPENFILENAME". Can anyone kindly lemme know how do I achieve this in a VC++ program. Thanks in advance.
GetOpenFileName does not support folder selection at all.
Your options are:
SHBrowseForFolder which is available on Windows 2000 and later, but looks a bit ugly.
IFileDialog which is the platform native folder chooser, but only available on Vista or later. To make the dialog behave as a folder picker, pass FOS_PICKFOLDERS to SetOptions.
In my opinion the best result for the user is to use IFileDialog where available, but fall back to SHBrowseForFolder for older operating systems.
There's ShBrowseForFolder. Plenty of C++ examples around if you search.
I can't be clearer than my title. :P
I want to run my program whenever a user renames a file in Windows Explorer (and only within the Explorer). Here's a simple mock up:
A simple link to a tutorial will be very helpful. I couldn't find anything. :/
Thank you in advance.
P.S. I'm new in C++
It looks like Windows API hooking may be your best bet. You'll want to intercept all calls related to Windows file renaming (i.e. MoveFile, MoveFileEx, SHFileOperation, possibly more). There are a few commercial and open source solutions; Microsoft Detours, Madshi's madCodeHook, and the free, open source EasyHook.
This approach, when done correctly, will allow you to capture all file renaming on a system.
I would avoid hooking APIs as much as possible. It gets really ugly really fast.
There are 2 ways I see that you can approach this.
Both ways have a few common factors:
The ReadDirectoryChangesW API. For a very good implementation of that API, see this
article
You will need to minimize your dependencies, so... Use a Microsoft compiler, link to the DLL runtime, stick to C as much as possible etc. This reduces problems. Loading things into the shell memory space is already problematic enough.
Method one is to use ReadDirectoryChangesW from an Explorer shell extension that does nothing else. Keep it minimal. I'm reasonably sure I saw a "do nothing" shell extension as an example in some of Microsoft's documentation.
Method two would be to package your code as a DLL and use a system hook to get your DLL loaded into Explorer only. The system hook should only load inside Explorer to prevent spurious notifications via ReadDirectoryChangesW.
Hope this helps and that you're not using it for something Evil.
Greetings!
I am trying to check directory write-permissions from within a Windows MFC/ATL program using C++. My first guess is to use the C-standard _access function, e.g.:
if (_access("C:\mydir", 2) == -1)
// Directory is not writable.
But apparently on Windows 2000 and XP, _access can't determine directory permissions. (i.e. the Security tab in the Properties dialog when you right-click on a directory in Explorer) So, is there an elegant way to determine a directory's write-permissions in Windows 2000/XP using any of the Windows C++ libraries? If so, how?
Thanks
Evan
You can call CreateFile with GENERIC_WRITE access to check this.
http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx
It's not a C++ library but it still counts as elegant because it directly does what you want...
Use sec api.
You can ask on Adv. Win32 api newsgroup :
news://194.177.96.26/comp.os.ms-windows.programmer.win32
where it has often been discussed (C/C++ code)
There are many Windows security functions, although I wouldn't call their usage particularly elegant. I would recommend GetNamedSecurityInfo as a general solution, but the CreateFile solution has a certain simplicity and directness which I can also appreciate. :)