BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Q: Cannot control vista api "SHGetKnownFolderPath" using she

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Wed Feb 21, 2007 9:11 am    Post subject: Q: Cannot control vista api "SHGetKnownFolderPath" using she Reply with quote



Q: Cannot control vista api "SHGetKnownFolderPath" using shell32.dll
in Delphi 7 on Windows XP.

OS: Windows XP
Target: Windows Vista
RAD: Delphi 7 (on Windows XP)

Below code which vista api in shell32.dll as dynamic-loading has
access violation error.
I wanna get user's (shared) folder full path so,
i've coded using vista api "SHGetKnownFolderPath" as a function
pointer by dynamic-load "shell32.dll".
Okay, i think function pointer works good, but i don't know exactly
why write to my array variable(call-by-reference)
at "SHGetKnownFolderPath" in "shell32.dll".

Let me know what is problem. Any help is truly appreciated.
thanks.

Best Regards,
godmode2k



// CODE
//
-------------------------------------------------------------------------------
....

type
TSHGetKnownFolderPath = function(FOLDERID_LocalAppDataLow: TGUID;
dwFlags: DWord; hToken: THandle; ppSzPath: pAnsiChar ) : HResult;
StdCall;

const
PRODUCT_BUSINESS = $00000006;
PRODUCT_HOME_BASIC = $00000002;
PRODUCT_HOME_PREMIUM = $00000003;
PRODUCT_STARTER = $0000000B;
PRODUCT_UNDEFINED = $00000000;
PRODUCT_ULTIMATE = $00000001;
PRODUCT_UNLICENSED = $ABCDABCD;
FOLDERID_LocalAppDataLow : TGUID =
(D1:$A520A1A4; D2:$1780; D3:$4FF6; D4:($BD,$18,$16,$73,$43,$C5,$AF,
$16));

var
....

m_SHGetKnownFolderPath: TSHGetKnownFolderPath;
m_pDllData: Pointer;
m_DllDataSize: Integer;
m_pMemoryModule: PBTMemoryModule;
m_hDll: Cardinal;

....

function BT_SHGetKnownFolderPath_File : BOOL;
begin
m_hDll := LoadLibrary( 'shell32.dll' );
...
@m_SHGetKnownFolderPath := GetProcAddress( m_hDll,
'SHGetKnownFolderPath' );
...
end;

function Vista_GetEnvironment : String;
var
// szPath: pAnsiChar;
szPath: array[0..MAX_PATH] of Char;
ret: HResult;
begin
BT_SHGetKnownFolderPath_File;

//
// Occurs error below line
// Message: Access Violation at address 75F15324 in module
'shell32.dll'. Write of address 16AFC543.
//
ret := m_SHGetKnownFolderPath( FOLDERID_LocalAppDataLow, 0, 0,
szPath );
...
if( m_hDll <> 0 ) then
begin
FreeLibrary( m_hDll );
end;
end;
//
-------------------------------------------------------------------------------

EOF
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.