Win32 |
Author |
Message |
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Wed Jun 28, 2006 9:18 am Post subject: Shell Operations |
|
|
SHCreateDirectoryEx: CreateDirectory and full path
"... It should create all subdirectories in the current one, nested and all.
I seem to recall this should work -- you guessed right, it didn't."
Last edited by delovski on Tue Apr 03, 2007 8:41 am; edited 1 time in total |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Thu Oct 12, 2006 7:24 pm Post subject: |
|
|
CSIDL_COMMON_DOCUMENTS returns E_INVALIDARG on XP?
>> // hr == E_INVALIDARG on my XP-SP2 system
>> HRESULT hr = SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_DOCUMENTS, &pidl);
> I don't now if this applies to this function, but some functions were
> superceded with updated ones in shfolder.dll. If you called the old
> version in shell32.dll you may get old behaviour?
> Have you tried using SHGetFolderPath instead?
You're right. That works. |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Thu Oct 19, 2006 9:48 pm Post subject: |
|
|
Google Groups: Window icon changes with change in file extension
"The function ExtractAssociatedIcon() does *precisely* what the shell does (!).
From MSDN:
HICON ExtractAssociatedIcon(HINSTANCE hInst, LPTSTR lpIconPath, LPWORD lpiIcon );
[...]
lpIconPath: Pointer to a string that specifies the full path and file name
of the file that contains the icon. The function extracts the icon handle
from that file, or from an executable file associated with that file." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Wed Nov 08, 2006 11:23 pm Post subject: |
|
|
Remove complete folder tree
"Anyone know of an API method to remove a complete folder tree? E.g., given
a starting folder, that folder and any sub folders are deleted - even if any
of them contain files." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Mon Nov 27, 2006 11:00 am Post subject: |
|
|
SHFileOperation fails to delete files
"I want to delete the files in a given directory. I'm using the following
test function and SHFileOperation(). It compiles cleanly, but when run a
message box pops up saying: Cannot delete file: Cannot read from the
source file or disk." |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Fri Jan 19, 2007 7:20 pm Post subject: |
|
|
RC: What does the fCreate parameter to SHCreateStreamOnFileEx mean?
"The documentation for the fCreate parameter for the SHCreateStreamOnFileEx
function covers the issue, but since people seem to really like charts and tables,
I'll present the same information in tabular form." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Sun Apr 29, 2007 1:10 pm Post subject: |
|
|
cboard: MFC Open directory dialog box
Answer came in the form of the api version with an optional start folder:
Code: | "// HWND is the parent window.
// szCurrent is an optional start folder. Can be NULL.
// szPath receives the selected path on success. Must be MAX_PATH characters in length.
BOOL BrowseForFolder(HWND hwnd, LPCTSTR szCurrent, LPTSTR szPath)" |
|
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Tue May 08, 2007 12:55 am Post subject: |
|
|
msdn: Extending Shortcut Menus
"Right-clicking an object on Microsoft Windows 95 and later systems usually
pops up a shortcut menu. This menu contains a list of commands that the
user can select to perform various actions on the object. This section is an
introduction to shortcut menus for file system objects." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Mon Oct 15, 2007 10:21 pm Post subject: |
|
|
Old New Thing: Why aren't shortcuts as easy as unix links?
"Now, you could create a similar single function that did all the heavy shell
lifting for you for each case (and in fact that's what I did last time I had to
make an installer that added its own shortcuts). OTOH, should every prog-
rammer have to reinvent the wheel?" |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Wed Feb 20, 2013 9:33 pm Post subject: |
|
|
codeguru.com - ShellExecuteEx()
Code: | SHELLEXECUTEINFO ExecuteInfo;
memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
ExecuteInfo.cbSize = sizeof(ExecuteInfo);
ExecuteInfo.fMask = 0;
ExecuteInfo.hwnd = 0;
ExecuteInfo.lpVerb = "open"; // Operation to perform
ExecuteInfo.lpFile = "c:\\windows\\notepad.exe"; // Application name
ExecuteInfo.lpParameters = "c:\\example.txt"; // Additional parameters
ExecuteInfo.lpDirectory = 0; // Default directory
ExecuteInfo.nShow = SW_SHOW;
ExecuteInfo.hInstApp = 0;
if(ShellExecuteEx(&ExecuteInfo) == FALSE)
// Could not start application -> call 'GetLastError()'
|
or cboard: ShellExecuteEx
Code: | SHELLEXECUTEINFO Info;
std::string FileName;
FileName = "C:\\MyFile.txt";
ZeroMemory(&Info, sizeof(SHELLEXECUTEINFO));
Info.cbSize = sizeof(SHELLEXECUTEINFO);
Info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
Info.lpFile = FileName.c_str();
Info.hInstApp = GetModuleHandle(NULL);
Info.nShow = SW_SHOW;
if(!ShellExecuteEx(&Info)) return FALSE;
//The created process is in:
Info.hProcess; |
Last edited by Ike on Wed Mar 06, 2013 9:28 pm; edited 2 times in total |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Wed Feb 20, 2013 9:35 pm Post subject: |
|
|
msdn - ShellExecuteEx() + SHELLEXECUTEINFO structure
"Because ShellExecuteEx can delegate execution to Shell extensions (data
sources, context menu handlers, verb implementations) that are activated
using Component Object Model (COM), COM should be initialized before
ShellExecuteEx is called. Some Shell extensions require the COM single-
threaded apartment (STA) type."
Last edited by Ike on Wed Mar 06, 2013 9:35 pm; edited 1 time in total |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Wed Feb 20, 2013 9:44 pm Post subject: |
|
|
Or just:
Code: | ShellExecute(NULL,"Open", "C:\\windows\\notepad.exe",NULL,NULL,SW_SHOWNORMAL);
|
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Thu Feb 21, 2013 10:38 pm Post subject: |
|
|
developpez.net - shellexecute vista privilege runasadmin
Code: | procedure RunAsAdmin(hWnd : HWND; aFile : String; aParameters : String);
Var
Sei : TShellExecuteInfoA;
begin
Fillchar(sei,SizeOf(sei),0);
sei.cbSize := SizeOf(sei);
sei.Wnd := hWnd;
sei.fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
sei.lpfile := PChar(aFile);
sei.lpVerb := 'runas';
sei.lpParameters := PChar(aParameters);
sei.nShow := SW_SHOWNORMAL;
if not ShellExecuteEx(@sei) then
RaiseLastOSError;
end;
RunAsAdmin(Application.Handle,'c:\test.exe',''); |
|
|
Back to top |
|
|
|