Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Windows Shell Programming or something else?

Posted on 2001-08-21
10
Medium Priority
?
308 Views
Last Modified: 2006-11-17
Hi,

I have a windows application which displays a list of files (available on shared resources on the network) in a list view.The application has a context menu enabled on the list view. I need to accomplish 2 tasks:
1. On clicking on a menu named "Properties", i need to show the property page for the file selected (as in Windows Explorer).
2. In the list view control, in a parallel column, i need to show the file type. For example, if the file is a zip file, the type would be displayed as WinZip files (as in Windows Explorer).

I've tried some shell programming using IShellFolder, but I'm unable to proceed. For displaying the properties page, I tried using ShellExecute with the "properties" verb but that is not working.
Are there any other ways?

Thanks.
0
Comment
Question by:smnaha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 4

Accepted Solution

by:
jtwine100697 earned 400 total points
ID: 6412261
For the "file type" part, look into the "SHGetFileInfo" function.  That function can get you the icon, type name, and other stuff.

For the "Properties" part, I recently experienced a similar problem (on Win2K): ShellExecute no longer brought up the Windows Explorer Properties Sheet for files(!).

However, the following code works for me (spacing and indenting will get trashed...):

     SHELLEXECUTEINFO     sei;
     TCHAR               caFilePath[ _MAX_PATH + 1 ];

     //
     // Get FileName Into caFilePath...
     //
     ::memset( &sei, 0, sizeof( SHELLEXECUTEINFO ) );
     sei.cbSize = sizeof( SHELLEXECUTEINFO );
     sei.lpFile = caFilePath;
     sei.lpVerb = "properties";
     sei.fMask  = SEE_MASK_INVOKEIDLIST;

     ::ShellExecuteEx( &sei );

   Hope that helps you out...

-=- James.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6413011
By the way, there is an excellent book on this subject that you may want to consider buying.  It's called Windows Shell Programming by Dino Esposito and publiched by WROX.
0
 
LVL 1

Author Comment

by:smnaha
ID: 6413185
Hi James,

Thanks for the ShellExecuteEx information. It works!
Regarding SHGetFileInfo(), the function works only for .txt documents. Is it possible to get the same context menu that windows explorer provides?
Perhaps I need to get that WROX book :-).

-smnaha
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Expert Comment

by:jtwine100697
ID: 6413437
!!!

SHGetFileInfo(...) should work for all registered file types on your system!  If it is not working for you, please post a snippet on how you are trying to use it, and what error code you are getting back.

As far as the context menu goes, I cannot help you there.  

I have the book that jhance mentions,strange looking guy, that Dino! :), but just retyping what is in a book is not the mark of an "expert".  I would suggest getting the book, however, it will be $39.99(USD) well spent!

-=- James.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6413484
>> but just retyping what is in a book is not the mark of an "expert"

I hope you're weren't implying that this was my comment...

The book is an excellent resource because it explains how this entire area of SHELL programming works.  So rather than just get the book to copy a few lines of code, the book has the WHYs and HOWs of this to provide a basic understanding of this poorly documented (by Microsoft anyway) area.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6413582
Hope is all we have sometimes... :)  

But worry not.  (My history on this site should make that clear.)

I just meant that my providing an "answer" by retyping half of a page from the book would be inappropriate.  That is why I suggested obtaining an copy of the book directly.

-=- James.
0
 
LVL 1

Author Comment

by:smnaha
ID: 6416890
Earlier I didn't pass the SHGFI_USEFILEATTRIBUTES flag.
So I was getting the type name only for .txt files. Now I'm getting the type name for most of the files but not all the files (.HTM, .ASP files return "")

WIN32_FIND_DATA FindFileData;
SHFILEINFO sfi;
//FindFileData gets populated here

SHGetFileInfo(FindFileData.cFileName, FindFileData.dwFileAttributes,
&sfi, sizeof(sfi), SHGFI_USEFILEATTRIBUTES |SHGFI_TYPENAME|SHGFI_ICON  );
                   
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6417492
Just for S&G, try this:

     ::SHGetFileInfo( FindFileData.cFileName, 0, &sfi, sizeof( sfi ), SHGFI_TYPENAME );

-=- James.
0
 
LVL 1

Author Comment

by:smnaha
ID: 6450485
Thanks, now things work fine.
Sorry for the delayed reply.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6450960
NP..  Feel free to contact me if you need any further assitance.

-=- James.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question