Question SHBrowseForFolder (shell32 API) raising exception in 64 bit OS (Windows 7)

Developer111

Member
Joined
Apr 21, 2010
Messages
24
Programming Experience
5-10
Hi,

I had developed an application in VS 2008 which uses ‘SHBrowseForFolder’ method of shell32.dll for browsing of files as well as folders. i.e. I can get path of folder only or path of file only as per requirement. I used it as following.

Private Declare Function SHBrowseForFolder Lib "shell32" (ByRef lpbi As BrowseInfo) As Integer

Every thing works fine when I run my application in 32 bit OS (i.e. Win XP) and also in 64 bit OS (Window 7 x64) after compiling it using ‘Target CPU’ option to ‘X86’, but when I compile it after setting ‘Target CPU’ option to ‘Any CPU’, the ‘SHBrowseForFolder’ function throws following exception in 64 bit OS (i.e. Windows 7 x64) i.e.

“Attempted to read or write protected memory. This is often an indication that other memory is corrupt”

I get Browse methods and able to Browse File or Folder individually but fails to Browse them simultanously.

How I can use same API for 64 bit OS? And if it is not possible then what can be its alternate?


Thanks in advance.
 
Back
Top