Igor Delovski Board Forum Index Igor Delovski Board
My Own Personal Slashdot!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Shell Operations

 
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> Win32
Win32  
Author Message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Wed Jun 28, 2006 9:18 am    Post subject: Shell Operations Reply with quote

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
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Thu Oct 12, 2006 7:24 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Thu Oct 19, 2006 9:48 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Wed Nov 08, 2006 11:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Mon Nov 27, 2006 11:00 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Fri Jan 19, 2007 7:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Sun Apr 29, 2007 1:10 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Tue May 08, 2007 12:55 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Mon Oct 15, 2007 10:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3522
Location: Zagreb

PostPosted: Wed Oct 15, 2008 11:55 pm    Post subject: Reply with quote

SO - How do you programmatically eject an USB mass storage device?

"It basically comes from this Microsoft article and uses kernel32.dll DeviceIoControl function"
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Wed Feb 20, 2013 9:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Wed Feb 20, 2013 9:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Wed Feb 20, 2013 9:44 pm    Post subject: Reply with quote

Or just:

Code:
ShellExecute(NULL,"Open", "C:\\windows\\notepad.exe",NULL,NULL,SW_SHOWNORMAL);
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3026
Location: Europe

PostPosted: Thu Feb 21, 2013 10:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> Win32 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Delovski.hr
Powered by php-B.B. © 2001, 2005 php-B.B. Group