Hi
How do I convert a lptstr var (win32) to a string var ?
Thanks
Inpromptu

Mailing lists / fpc-pascal / 2004-04
5 messages · 4 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi
How do I convert a lptstr var (win32) to a string var ?
Thanks
Inpromptu
Hi How do I convert a lptstr var (win32) to a string var ?
lptstr is just a PChar. Use the usual method you use for PChar...
Y := StrPas( X );
Y := String(X);Would probably both work in Delphi mode - though StrPas is more universal.
strpas will introduce a 255 char limit.
Hi:
I was looking the demo sources, and I found c:\pp\demo\win32\edit.pp VERY interesting. So, i decide to try shBrowseForFolder instead of GetOpenFilename, but I don't know wath I'm doing wrong...
This is my humble little program... be nice with the criticims... !
{----------begin of program------------}
program myprogram;
uses windows;
const
COINIT_APARTMENTTHREADED=2;{from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/cme_a2d_4oqc.asp }var
myDir:browseinfo; {from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/structures/browseinfo.asp }
function CoInitializeEx(pvReserved:pointer;dwCoInit:dword):UINT;external 'ole32' name 'CoInitializeEx'; {from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/cmf_a2c_5iyg.asp }
procedure CoTaskMemFree(var pv:pointer);external 'ole32' name 'CoTaskMemFree'; {from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/cmf_a2c_63l1.asp }
var
Dir:browseinfo;
fpath:string;
{-------------------------------------------------------}
function SelectDir:string;
var
items:lpitemidlist;
aux:lptstr;
aux2:string;
i:integer;
begin
with myDir do
begin
HWndOwner := 0;{?????}
pidlRoot :=null;
;
lpszTitle:='Hello...';
ulFlags:=0;
{ulFlags:=??;}
lpfn:=null;
{bffcallback:=???;}
end;
i:=coinitializeex(null,COINIT_APARTMENTTHREADED);{following instructions from shBrowseForFolder}
items:=shBrowseForFolder(@Dir);{from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shbrowseforfolder.asp}
if not(shGetPathFromIDList(items,@aux)) then begin writeln('failed...');halt; end;
aux2:=strpas(@aux);{hey !, lptstr to string was not the problem !!!}{halt;}
{If you don't halt here, you'll get an Access violation...}
CoTaskMemFree(items);{following instructions from shBrowseForFolder example}
SelectDir:=aux2;
end;{function}
{--------------------------------------------------------}
begin
writeln('Please, select a dir until this program crash:');
writeln('You pick ',SelectDir);
writeln('Please, pick a deeper dir, c:\program files\other\other\... or I will not crash...' );
end.{----------end of program------------}
Thank you very, very, very much !!!!!!
Inpromptu
Hi,
[trim]
Ok, enough advertising microsoft.com for now... ;-) See some working example below, hope it helps.
Don't forget to specify -Sd option.