SHGetFolderPath external call

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

SHGetFolderPath external call

Sergei Gnezdov
Hi,

I am sure it is very simple, but I can't get it right.  I probably
messed up in mapping and in a way to make a call.

I am trying to call shell32.dll function:

HRESULT SHGetFolderPath(HWND hwndOwner,
    int nFolder,
    HANDLE hToken,
    DWORD dwFlags,
    LPTSTR pszPath
);

I placed a call into ShellLibrary class.

SHGetFolderPath: hwndOwner folder: nFolder hToken: hToken dwFlags:
dwFlags pszPath: pszPath
        <stdcall: HRESULT SHGetFolderPathA DWORDField* WORD
DWORDField* DWORD LPSTR*>
        ^self invalidCall

I am calling from workspace:

lib := ShellLibrary default.
str :=LPSTR new: 300.
lib SHGetFolderPath: nil folder: 26 hToken: nil dwFlags: 0 pszPath:
str.

The error I get is in str object:

an invalid LPSTR [Invalid access to memory location. Reading
0x445C3A43, IP 0x1199580 (C:\Program Files\Common Files\Object
Arts\Dolphin Smalltalk 5.1\DolphinVM005.dll)]

Evaluate the following expression to debug:
        self printString


Reply | Threaded
Open this post in threaded view
|

Re: SHGetFolderPath external call

Roberto Lupi-2
In article <[hidden email]>, sergei-gnezdov-
[hidden email] says...

> Hi,
>
> I am sure it is very simple, but I can't get it right.  I probably
> messed up in mapping and in a way to make a call.
> I am calling from workspace:
>
> lib := ShellLibrary default.
> str :=LPSTR new: 300.
> lib SHGetFolderPath: nil folder: 26 hToken: nil dwFlags: 0 pszPath:
> str.

Try this code:

lib := ShellLibrary default.
str := String new: 300.
lib SHGetFolderPath: nil folder: 26 hToken: nil dwFlags: 0 pszPath: str
asParameter.

--
Roberto Lupi


Reply | Threaded
Open this post in threaded view
|

Re: SHGetFolderPath external call

Chris Uppal-3
In reply to this post by Sergei Gnezdov
Sergei Gnezdov wrote:

> I am trying to call shell32.dll function:
>
> HRESULT SHGetFolderPath(HWND hwndOwner,
>     int nFolder,
>     HANDLE hToken,
>     DWORD dwFlags,
>     LPTSTR pszPath
> );

Take a look at the implementation of ShellLibrary>>findExecutable:directory:

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: SHGetFolderPath external call

Louis Sumberg-2
In reply to this post by Sergei Gnezdov
Just a reminder, there's already a set of packages that wrap much of the
functionality of the Windows Shell, including the function below.  See
http://www.dolphinharbor.org/dh/projects/shell/index.html for more info.

-- Louis

"Sergei Gnezdov" wrote
> I am trying to call shell32.dll function:
>
> HRESULT SHGetFolderPath(HWND hwndOwner,
>     int nFolder,
>     HANDLE hToken,
>     DWORD dwFlags,
>     LPTSTR pszPath


Reply | Threaded
Open this post in threaded view
|

Re: SHGetFolderPath external call

Sergei Gnezdov
On Mon, 16 Jun 2003 06:33:01 -0700, "Louis Sumberg"
<[hidden email]> wrote:

>Just a reminder, there's already a set of packages that wrap much of the
>functionality of the Windows Shell, including the function below.  See
>http://www.dolphinharbor.org/dh/projects/shell/index.html for more info.
>
>-- Louis

Thanks, that's good to know.  Less code to write is better :)

>"Sergei Gnezdov" wrote
>> I am trying to call shell32.dll function:
>>
>> HRESULT SHGetFolderPath(HWND hwndOwner,
>>     int nFolder,
>>     HANDLE hToken,
>>     DWORD dwFlags,
>>     LPTSTR pszPath
>


Reply | Threaded
Open this post in threaded view
|

Re: SHGetFolderPath external call

Sergei Gnezdov
In reply to this post by Roberto Lupi-2
On Mon, 16 Jun 2003 07:11:56 GMT, Roberto Lupi <[hidden email]>
wrote:

>In article <[hidden email]>, sergei-gnezdov-
>[hidden email] says...
>> Hi,
>>
>> I am sure it is very simple, but I can't get it right.  I probably
>> messed up in mapping and in a way to make a call.
>> I am calling from workspace:
>>
>> lib := ShellLibrary default.
>> str :=LPSTR new: 300.
>> lib SHGetFolderPath: nil folder: 26 hToken: nil dwFlags: 0 pszPath:
>> str.
>
>Try this code:
>
>lib := ShellLibrary default.
>str := String new: 300.
>lib SHGetFolderPath: nil folder: 26 hToken: nil dwFlags: 0 pszPath: str
>asParameter.

It works!  It was not hard after all :)


Thank you