PeterdeB
asked on
About the Create new short cut dialog
Hi Folks,
How can I get this >>>
procedure TForm2.Button1Click(Sender : TObject);
var si: _STARTUPINFOA;
pi: _PROCESS_INFORMATION;
begin
ZeroMemory(@si, SizeOf(si));
si.cb := SizeOf(si);
si.lpDesktop := nil;
si.dwFlags := STARTF_USESHOWWINDOW;
si.wShowWindow := SW_SHOWDEFAULT;
CreateProcess(nil, 'rundll32 appwiz.cpl NewLinkHere c:\', nil, nil, false,
0, nil, nil, si, pi);
end;
To use the SendTo folder instead of the c: drive? I gave my best shot but its toooo much abacadabra for me, passing it anyhthing else instead of a hard coded path.
Kind regards,
Dweep
How can I get this >>>
procedure TForm2.Button1Click(Sender
var si: _STARTUPINFOA;
pi: _PROCESS_INFORMATION;
begin
ZeroMemory(@si, SizeOf(si));
si.cb := SizeOf(si);
si.lpDesktop := nil;
si.dwFlags := STARTF_USESHOWWINDOW;
si.wShowWindow := SW_SHOWDEFAULT;
CreateProcess(nil, 'rundll32 appwiz.cpl NewLinkHere c:\', nil, nil, false,
0, nil, nil, si, pi);
end;
To use the SendTo folder instead of the c: drive? I gave my best shot but its toooo much abacadabra for me, passing it anyhthing else instead of a hard coded path.
Kind regards,
Dweep
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Folks!
Got it working now using the code from CodedK. Had to modify it a bit but now it works!
Here goes >>
//
function Launch_CreateShortCut_Dial og(Directo ry: string): Boolean;
var
reg: TRegistry;
cmd: string;
begin
Result := False;
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_CLASSES_ROOT;
if reg.OpenKeyReadOnly('.LNK\ ShellNew') then
begin
cmd := reg.ReadString('Command');
cmd := StringReplace(cmd, '%1', Directory+'\', []);
// I added +'\' otherwise it would rename the sendto directory into the name of the selected item
// into the name of the item to which we were linking
Result := True;
WinExec(PChar(cmd), SW_SHOWNORMAL);
end
finally
reg.Free;
end;
end;
{Example/ Beispiel}
function GetSendToFolder: string;
var
pIDL: pItemIDList;
Buffer: array[0..MAX_PATH] of char;
Malloc: IMalloc;
begin
SHGetSpecialFolderLocation (0, CSIDL_SENDTO, pIDL);
ShGetPathFromIdList(pIDL, PChar(@Buffer));
Result := Buffer;
OLECheck(SHGetMalloc(Mallo c));
if pIDL <> nil then
Malloc.Free(pIDL);
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
Launch_CreateShortCut_Dial og(GetSend ToFolder);
end;
//
Kind regards,
Dweep
PS RemkoEB > I couldnt get it to work using your piece of code
Got it working now using the code from CodedK. Had to modify it a bit but now it works!
Here goes >>
//
function Launch_CreateShortCut_Dial
var
reg: TRegistry;
cmd: string;
begin
Result := False;
reg := TRegistry.Create;
try
reg.Rootkey := HKEY_CLASSES_ROOT;
if reg.OpenKeyReadOnly('.LNK\
begin
cmd := reg.ReadString('Command');
cmd := StringReplace(cmd, '%1', Directory+'\', []);
// I added +'\' otherwise it would rename the sendto directory into the name of the selected item
// into the name of the item to which we were linking
Result := True;
WinExec(PChar(cmd), SW_SHOWNORMAL);
end
finally
reg.Free;
end;
end;
{Example/ Beispiel}
function GetSendToFolder: string;
var
pIDL: pItemIDList;
Buffer: array[0..MAX_PATH] of char;
Malloc: IMalloc;
begin
SHGetSpecialFolderLocation
ShGetPathFromIdList(pIDL, PChar(@Buffer));
Result := Buffer;
OLECheck(SHGetMalloc(Mallo
if pIDL <> nil then
Malloc.Free(pIDL);
end;
procedure TForm1.Button1Click(Sender
begin
Launch_CreateShortCut_Dial
end;
//
Kind regards,
Dweep
PS RemkoEB > I couldnt get it to work using your piece of code
CreateProcess(nil, 'rundll32 appwiz.cpl NewLinkHere "%userprofile%\sendto"', nil, nil, false,
0, nil, nil, si, pi);