Link to home
Start Free TrialLog in
Avatar of PeterdeB
PeterdeBFlag for Netherlands

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
ASKER CERTIFIED SOLUTION
Avatar of CodedK
CodedK
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The "path" of the Send To folder is usually "%userprofile%\sendto"
CreateProcess(nil, 'rundll32 appwiz.cpl NewLinkHere "%userprofile%\sendto"', nil, nil, false,
    0, nil, nil, si, pi);
Avatar of PeterdeB

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_Dialog(Directory: 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(Malloc));
  if pIDL <> nil then
    Malloc.Free(pIDL);
end;

procedure TForm1.Button1Click(Sender: TObject);

begin
  Launch_CreateShortCut_Dialog(GetSendToFolder);
end;
//

Kind regards,

Dweep

PS RemkoEB > I couldnt get it to work using your piece of code