Re: [BLACKBOX] Getting the User\Local Settings\Application Data\ path

From: [at]} <Aubrey.McIntosh{>
Date: Thu, 24 Jan 2008 18:15:03 -0600

----boundary-LibPST-iamunique-202318239_-_-
Content-type: text/plain

I'm interested in this. I spent a few minutes with it doing an end of
day mindless copy, and I don't get a clean compile.
Could you dress it up a little so it will write the string to the log?


On Jan 24, 2008 5:13 PM, Marc Martin <marc{([at]})nowhere.xy
> Hi all,
>
> Occasionally I find that WinApi is missing some standard
> Windows API functions and constants. For example, today
> I wanted to get the path to the User's Local Settings\Application Data
> folder. I couldn't find the relevant functions or constants in
> WinApi, so I had to do some Google searches and figure out
> how to make my own. For the benefit of anyone who wants to do
> the same thing, the following works:
>
>
> STEP 1: DEFINE THE CONSTANTS and FUNCTION ----------------------
>
> MODULE MoreApi ["KERNEL32.dll"];
>
> IMPORT WinApi;
>
> CONST
> CSIDL_LOCAL_APPDATA* = 1CH;
> CSIDL_FLAG_CREATE* = 8000H;
> SHGFP_TYPE_CURRENT* = 0;
> SHGFP_TYPE_DEFAULT* = 1;
>
> PROCEDURE SHGetFolderPath* ["SHELL32.dll", "SHGetFolderPathW"]
> ( hwndOwner: WinApi.HWND;
> nFolder: INTEGER;
> hToken: WinApi.HANDLE;
> dwFlags: INTEGER;
> VAR [nil] pszPath: ARRAY [untagged] OF CHAR ):
> INTEGER;
>
> ----------------------------------------------------------------
>
> STEP 2: CALL THE NEW FUNCTION ----------------------------------
>
> PROCEDURE Do*;
> VAR
> result: INTEGER;
> path: ARRAY [untagged] WinApi.MAX_PATH OF CHAR;
> BEGIN
> result := MoreApi.SHGetFolderPath
> ( WinApi.NULL,
> StatApi.CSIDL_LOCAL_APPDATA + StatApi.CSIDL_FLAG_CREATE,
> WinApi.NULL,
> StatApi.SHGFP_TYPE_CURRENT,
> path );
>
> ----------------------------------------------------------------
>
> This was more difficult than I would have expected, because
> I expected the functions and constants to be predefined!
>
> Marc
>
>
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
>



-- 
-- 
Aubrey McIntosh, Ph.D.
1502 Devon Circle
Austin TX 78723-1814
http://home.grandecom.net/~amcintosh/aubrey/Search/
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-202318239_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEknbSBpbnRlcmVzdGVkIGluIHRoaXMuICBJIHNw
ZW50IGEgZmV3IG1pbnV0ZXMgd2l0aCBpdCBkb2luZyBhbiBlbmQgb2ZccGFyDQpkYXkgbWluZGxl
c3MgY29weSwgYW5kIEkgZG9uJ3QgZ2V0IGEgY2xlYW4gY29tcGlsZS5ccGFyDQpDb3VsZCB5b3Ug
ZHJlc3MgaXQgdXAgYSBsaXR0bGUgc28gaXQgd2lsbCB3cml0ZSB0aGUgc3RyaW5nIHRvIHRoZSBs
b2c/XHBhcg0KXHBhcg0KXHBhcg0KT24gSmFuIDI0LCAyMDA4IDU6MTMgUE0sIE1hcmMgTWFydGlu
IDxtYXJjQHVmb3Nlcmllcy5jb20+IHdyb3RlOlxwYXINCj4gSGkgYWxsLFxwYXINCj5ccGFyDQo+
IE9jY2FzaW9uYWxseSBJIGZpbmQgdGhhdCBXaW5BcGkgaXMgbWl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S0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tXHBhcg0KPlxwYXINCj4gVGhpcyB3YXMgbW9yZSBkaWZmaWN1bHQgdGhhbiBJIHdvdWxkIGhh
dmUgZXhwZWN0ZWQsIGJlY2F1c2VccGFyDQo+IEkgZXhwZWN0ZWQgdGhlIGZ1bmN0aW9ucyBhbmQg
Y29uc3RhbnRzIHRvIGJlIHByZWRlZmluZWQhXHBhcg0KPlxwYXINCj4gTWFyY1xwYXINCj5ccGFy
DQo+XHBhcg0KPiAtLS0tXHBhcg0KPiBUbyB1bnN1YnNjcmliZSwgc2VuZCBhIG1lc3NhZ2Ugd2l0
aCBib2R5ICJTSUdOT0ZGIEJMQUNLQk9YIiB0byBMSVNUU0VSVkBMSVNUUy5PQkVST04uQ0hccGFy
DQo+XHBhcg0KXHBhcg0KXHBhcg0KXHBhcg0KLS0gXHBhcg0KLS0gXHBhcg0KQXVicmV5IE1jSW50
b3NoLCBQaC5ELlxwYXINCjE1MDIgRGV2b24gQ2lyY2xlXHBhcg0KQXVzdGluIFRYIDc4NzIzLTE4
MTRccGFyDQpodHRwOi8vaG9tZS5ncmFuZGVjb20ubmV0L35hbWNpbnRvc2gvYXVicmV5L1NlYXJj
aC9ccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3JpYmUsIHNlbmQgYSBtZXNz
YWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNFUlZATElTVFMuT0JFUk9O
LkNIXHBhcg0KfQ==
----boundary-LibPST-iamunique-202318239_-_---
Received on Fri Jan 25 2008 - 01:15:03 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:31:07 UTC