Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Involking the create new shortcutdialog

Posted on 2007-10-12
4
Medium Priority
?
621 Views
Last Modified: 2008-01-09
Hi Folks,

This code I found at borland after I followed a link from a topic here about invoking the new shortcut dialog >

//
function InvokeShortCutDialog(Directory : string) : boolean;
var
  Reg : TRegistry;
  CmdLine : string;
begin
  Result := false;
  Reg := TRegistry.Create;
  try
    Reg.Rootkey := HKEY_CLASSES_ROOT;
    if Reg.OpenKeyReadOnly('.LNKShellNew') then
    begin
      CmdLine := Reg.ReadString('Command');
      CmdLine := StringReplace(CmdLine, '%1', Directory, []);
      Result := True;
      WinExec(PChar(CmdLine), SW_SHOWNORMAL );
    end
  finally
    Reg.free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  InvokeShortCutDialog('c:Temp');
end;

//

I can't get this to work however. This is supposed to work on windows 2000, I have xp sp2...should that be the problem?

Furthermore I found these pieces of code (traced back into sites reading right to left stead of left to right > this made it oh so difficult to get the right one I guess)

//
ShellExecute(0,'open','rundll','appwiz.cpl,NewLinkHere %1', 'c:\', SW_SHOWNORMAL);
This doesn't work either...why not?

//
WinExec('rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,3, '', SW_NORMAL);
Values of '','0', '1', '2', '3'  pop up either the installed software list or the add software or remove software list.....how do I get my hands on the new shortcut dialog?


Kind regards,

Dweep
0
Comment
Question by:PeterdeB
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:RemkoEB
ID: 20068362
Change this line ShellExecute(0,'open','rundll','appwiz.cpl,NewLinkHere %1', 'c:\', SW_SHOWNORMAL);
to
ShellExecute(0,'open','rundll32','appwiz.cpl,NewLinkHere %1', 'c:\', SW_SHOWNORMAL);

0
 

Author Comment

by:PeterdeB
ID: 20069782
Still can't get it to work...could it be Kaspersky that is blocking something?

Kind regards,

Dweep

Ps I don't expect you to answer this question, but I don't know why it doesn't work
0
 
LVL 3

Accepted Solution

by:
RemkoEB earned 2000 total points
ID: 20070513
The corrected syntax is this:
Create New Shortcut Wizard:
    'puts the new shortcut in the location specified by %1
    rundll32.exe AppWiz.Cpl,NewLinkHere %1

I tested the code below and that works for me:
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;

If you are using Vista look here: http://blogs.msdn.com/vistacompatteam/archive/2006/10/20/rundll32-exe-appwiz-cpl-newlinkhere-is-back.aspx
0
 

Author Comment

by:PeterdeB
ID: 20070565
Yes works like a charm thank you!! ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…

572 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