Simple Windows API Question

Windows specific questions.
falcron
Posts: 57
Joined: Jan 18, 2008 15:55

Simple Windows API Question

Postby falcron » Sep 21, 2009 21:40

I am looking to perform the following Windows API call and read its response and put it into a string variable.

Basically, I'm looking to get the location of localapplicationdata so that I can read some information.

The full API call is Environment.SpecialFolder.LocalApplicationData

Can someone show me a quick example on how to make this call to a CONSOLE based windows application? I looked at the Win API made easy but those seem very complex to me because they are creating windows, etc. I don't need to do any of that, just using windows console mode.

Cheers. :)

edit: Just using

Code: Select all

Environ("USERPROFILE") + "\Local Settings\Application Data\MyApplication\ApplicationUsers\"


Will not work because Windows will localize "Local Settings" and "Application Data" on other language OSes, thus it cannot be hard coded and must be pulled via an API call.
Hard
Posts: 135
Joined: Aug 29, 2008 21:13

Postby Hard » Sep 21, 2009 21:47

Environment.SpecialFolder.LocalApplicationData is .net

in other words: impossible to access it with fb
Zippy
Posts: 1295
Joined: Feb 10, 2006 18:05

Postby Zippy » Sep 21, 2009 22:12

Try:

Code: Select all

#include once "windows.bi"
#include once "win\shlobj.bi"
'
dim as string fpath=string(MAX_PATH,0)
dim as HRESULT hres

hres=SHGetFolderPath(_
        NULL,_
        CSIDL_LOCAL_APPDATA,_
        NULL,_
        SHGFP_TYPE_CURRENT,_
        strptr(fpath))
'
print hres 'if not zero then problem..
print trim(fpath)
'
sleep
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Postby dkl » Sep 21, 2009 22:12

Try SHGetFolderPath(): http://msdn.microsoft.com/en-us/library/bb762181.aspx

Code: Select all

#include "windows.bi"
#include "win/shlobj.bi"

dim as zstring * MAX_PATH path
print SHGetFolderPath( NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, @path )
print path
sleep
falcron
Posts: 57
Joined: Jan 18, 2008 15:55

Postby falcron » Sep 21, 2009 22:28

You guys...

are freaking geniuses.

:)

thanks!

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 4 guests