🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13287

Re: SHBrowseForFolder, BFFM_SETSELECTION, UNC paths (Windows bug?)

#13287
From: Remy Lebeau (TeamB)
Date: Sat, 18 Oct 2003 05:15
36 lines
2519 bytes
"Dennis Jones" <djones@nospam.com> wrote in message
news:3f90be9d@newsgroups.borland.com...

> My latest version of code that is SUPPOSED to work follows.
> Does anyone know why this does not work?  Is there a bug in
> Windows that prevents this code form functioning properly?

I tried your code as-is, under Win98, Win2K, and XP.  They all worked fine
for me.  I had no troubles initializing the dialog using UNC paths when they
are converted to PIDLs first, other then a few secnods delay while the OS
resolved the PIDLs for use.

With that in mind, I would like to make some extra comments:

1) you have several variables that are not initialized before use,
particularly your buffers.  You should always iniitialize buffers and
structures to zeros initially.  In some cases, the Win32 API actually
*requires* you to do so.  When you do not initialize buffers, the buffers
will be filled with random memory, which could cause members to contain
values that will cause API operations to fail.

2) for character buffers, you should allocate (MAX_PATH+1) characters, in
case you happen to try working with paths that are exactly MAX_PATH
characters in size, so that you always have extra room for a
null-terminator.

3) you should never use strcpy() because it does not protect against buffer
overflows.  Use either strncpy() or StrLCopy() instead.

4) to cut down on some code complexity, you can use CoTaskMemFree() instead
of using SHGetMalloc() and IMalloc::Free() manually.  CoTaskMemFree() uses
IMalloc internally.


Gambit
Technical Details
Message-ID: <3f90cbe6@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f90be9d@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,8dd37dadfc9c37c0
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-17 22:38:57 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f90be9d@newsgroups.borland.com>
Subject: Re: SHBrowseForFolder, BFFM_SETSELECTION, UNC paths (Windows bug?)
Date: Fri, 17 Oct 2003 22:15:26 -0700
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.137.75
Message-ID: <3f90cbe6@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1066453990 67.22.137.75 (17 Oct 2003 22:13:10 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail