Article View: borland.public.cppbuilder.nativeapi
Article #9979Re: invoke "file properties window"
From: Remy Lebeau (TeamB)
Date: Tue, 01 Jun 2004 22:34
Date: Tue, 01 Jun 2004 22:34
52 lines
2806 bytes
2806 bytes
"Mortz" <rmorteo@hotmail.com> wrote in message
news:40bcf046@newsgroups.borland.com...
> hInstance=LoadLibrary("SHELL32.DLL");
Use GetModuleHandle() instead. All processes have Shell32.dll linked into
them automatically at program startup. There is no need to re-load the DLL
again since it is already loaded by the time your application's code begin
running.
>
SHObjectProperties=(pSHObjectProperties)GetProcAddress(hInstance,(char
> *)178);
You are not checking to make sure that GetProcAddress() returns a non-NULL
pointer before calling SHObjectProperties().
> SHObjectProperties(hwnd,OPF_PATHNAME,(wchar_t *)file.c_str(),NULL);
> //perhaps the proble is the casting?
Yes, the casting is problematic. You cannot cast a char* to a wchar_t*, you
have to actually convert the data from one format to another. The easiest
way to do that is to use the WideString class, which will do the necessary
conversion internally for you.
> return true;
You should return the actual result of SHObjectProperties().
Try this code instead:
#ifndef SHOP_FILEPATH
#define SHOP_FILEPATH 0x00000002
#endif
bool DisplayFileProperties(HWND hwnd, const AnsiString &file)
{
pSHObjectProperties lpSHObjectProperties = (pSHObjectProperties)
GetProcAddress(GetModuleHandle("SHELL32"), MAKEINTRESOURCE(178));
if( lpSHObjectProperties )
{
if( lpSHObjectProperties(hwnd, SHOP_FILEPATH, WideString(file),
NULL) )
return true;
}
return ( ((int)ShellExecute(hwnd, "properties", file.c_str(), 0, 0,
SW_SHOWNORMAL)) > 32 );
}
Gambit
Technical Details
Message-ID:
<40bd058b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed.gamma.ru!Gamma.RU!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40bb54a2$1@newsgroups.borland.com> <40bb600f@newsgroups.borland.com> <40bca1c2$1@newsgroups.borland.com> <40bcbf5b$1@newsgroups.borland.com> <40bcf046@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,1de9d7beecb3f3a1 X-Google-Attributes: gid10cc67,public From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40bb54a2$1@newsgroups.borland.com> <40bb600f@newsgroups.borland.com> <40bca1c2$1@newsgroups.borland.com> <40bcbf5b$1@newsgroups.borland.com> <40bcf046@newsgroups.borland.com> Subject: Re: invoke "file properties window" Date: Tue, 1 Jun 2004 15:34:46 -0700 Lines: 54 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 67.22.135.163 Message-ID: <40bd058b$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1086129547 67.22.135.163 (1 Jun 2004 15:39:07 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed.gamma.ru!Gamma.RU!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail