SHCreateShortcut call behavior in ppc 2003 for link in start menu

  • Thread starter Thread starter cenright
  • Start date Start date
C

cenright

I have code to create a shortcut directly in the start
menu folder. This works fine in PPC 2002. However, in
PPC 2003 (both on dell axiom) the shortcut gets created
correctly (I can see it through explorer from the
attached pc) but as soon as I touch the start menu, the
os moves the shortcut from the '\windows\start menu'
folder into the '\windows\start menu\programs' folder.

Anybody else experiencing this / any workaround to
getting the link in the start menu folder?

Thanks...chuck

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.IO;


namespace CreateShortcut
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu
mainMenu1;

[ DllImport("coredll.dll",
EntryPoint="SHCreateShortcut") ]
private static extern bool
SHCreateShortcut(string shortcut, string target);

public Form1()
{
//
// Required for Windows Form
Designer support
//
InitializeComponent();

//get the fully qualified app name
string App =
System.Reflection.Assembly.GetExecutingAssembly
().GetModules()[0].FullyQualifiedName;


//create link file name
string Link = "\\windows\\start
menu\\" + Path.GetFileNameWithoutExtension(App) + ".lnk";

//go ahead and add link to the
start menu if not there...
if(!File.Exists(Link))
{
SHCreateShortcut
(Link, '"' + App + '"');
}

}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool
disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated
code
/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new
System.Windows.Forms.MainMenu();
//
// Form1
//
this.ClientSize = new
System.Drawing.Size(250, 280);
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Text = "Form1";

}
#endregion

/// <summary>
/// The main entry point for the
application.
/// </summary>

static void Main()
{
Application.Run(new Form1());
}

}
}
 
I saw similar behavior for a PPC 2003 we have, too. I created a CAB
file that, on a PPC 2002, creates an icon on the start menu and in Programs.
On a PPC 2003, no icon appears on the start menu and 2 icons appear in
Programs.

I didn't look at it much, but it must be a bug in PPC 2003.
 
This one sounds like you have the maximum number of items already shown on
the Start menu. I think the maximum is 9. If I try to create a 10th Start
Menu shortcut it appears on the program screen.

I now check how many *.lnk files already exist in the start menu and only
create a shortcut there if it is less than 9.

John.

Mark McKnight said:
I saw similar behavior for a PPC 2003 we have, too. I created a CAB
file that, on a PPC 2002, creates an icon on the start menu and in Programs.
On a PPC 2003, no icon appears on the start menu and 2 icons appear in
Programs.

I didn't look at it much, but it must be a bug in PPC 2003.

cenright said:
I have code to create a shortcut directly in the start
menu folder. This works fine in PPC 2002. However, in
PPC 2003 (both on dell axiom) the shortcut gets created
correctly (I can see it through explorer from the
attached pc) but as soon as I touch the start menu, the
os moves the shortcut from the '\windows\start menu'
folder into the '\windows\start menu\programs' folder.

Anybody else experiencing this / any workaround to
getting the link in the start menu folder?

Thanks...chuck

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.IO;


namespace CreateShortcut
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu
mainMenu1;

[ DllImport("coredll.dll",
EntryPoint="SHCreateShortcut") ]
private static extern bool
SHCreateShortcut(string shortcut, string target);

public Form1()
{
//
// Required for Windows Form
Designer support
//
InitializeComponent();

//get the fully qualified app name
string App =
System.Reflection.Assembly.GetExecutingAssembly
().GetModules()[0].FullyQualifiedName;


//create link file name
string Link = "\\windows\\start
menu\\" + Path.GetFileNameWithoutExtension(App) + ".lnk";

//go ahead and add link to the
start menu if not there...
if(!File.Exists(Link))
{
SHCreateShortcut
(Link, '"' + App + '"');
}

}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool
disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated
code
/// <summary>
/// Required method for Designer support -
do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new
System.Windows.Forms.MainMenu();
//
// Form1
//
this.ClientSize = new
System.Drawing.Size(250, 280);
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Text = "Form1";

}
#endregion

/// <summary>
/// The main entry point for the
application.
/// </summary>

static void Main()
{
Application.Run(new Form1());
}

}
}
 
Back
Top