?
Solved

About the Create new short cut dialog

Posted on 2007-10-13
3
Medium Priority
?
168 Views
Last Modified: 2010-04-05
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
0
Comment
Question by:PeterdeB
3 Comments
 
LVL 16

Accepted Solution

by:
CodedK earned 2000 total points
ID: 20070768
Hi.

I dont know if i understood your question but take a look at this function :

~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

uses
  registry, shellapi;

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, []);
      Result := True;
      WinExec(PChar(cmd), SW_SHOWNORMAL);
    end
  finally
    reg.Free;
  end;
end;

{Example/ Beispiel}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Launch_CreateShortCut_Dialog('c:\temp');
end;
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

Hope this helps.
0
 
LVL 3

Expert Comment

by:RemkoEB
ID: 20070959
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);
0
 

Author Comment

by:PeterdeB
ID: 20074563
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

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question