Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: converting aspx pages to HMTL pages Pin
Guffa6-Oct-05 0:06
Guffa6-Oct-05 0:06 
QuestionExecuting programs Pin
Stefan_ Spenz5-Oct-05 23:38
Stefan_ Spenz5-Oct-05 23:38 
AnswerRe: Executing programs Pin
Stefan Troschuetz5-Oct-05 23:48
Stefan Troschuetz5-Oct-05 23:48 
GeneralRe: Executing programs Pin
Stefan_ Spenz6-Oct-05 1:51
Stefan_ Spenz6-Oct-05 1:51 
AnswerRe: Executing programs Pin
User 66586-Oct-05 1:41
User 66586-Oct-05 1:41 
GeneralRe: Executing programs Pin
Stefan_ Spenz6-Oct-05 1:52
Stefan_ Spenz6-Oct-05 1:52 
Questionhow to get the target of shortcut Pin
Anonymous5-Oct-05 22:27
Anonymous5-Oct-05 22:27 
AnswerRe: how to get the target of shortcut Pin
Heath Stewart6-Oct-05 7:28
protectorHeath Stewart6-Oct-05 7:28 
The easiest way is to create a Runtime-Callable Wrapper (RCW) using tlbimp.exe from the .NET Framework SDK from shell32.dll. This contains the automation objects that you can use with managed code via the RCW.

To do this, run the following
tlbimp /out:Interop.Shell32.dll /namespace:Microsoft.Interop.Shell32.dll shell32.dll
You can then write code similar to the following using the Folder, FolderItem and ShellLinkObject classes:
using System;
using System.IO;
using Microsoft.Interop.Shell32;
 
class ShellLink
{
  const int ERROR_SUCCESS = 0;
  const int ERROR_FILE_NOT_FOUND = 2;
  const int ERROR_PATH_NOT_FOUND = 3;
  const int ERROR_INVALID_PARAMETER = 87;
 
  const string OUTPUT_FORMAT = "{0} -> {1}";
 
  static int Main(string[] args)
  {
    string directory, name = null;
    switch (args.Length)
    {
      case 0:
        directory = Environment.CurrentDirectory;
        break;
 
      case 1:
        directory = args[0];
        if ((directory[0] == '/' || directory[0] == '-') &&
          (directory[1] == '?' || directory[1] == 'h'))
        {
          Usage(Console.Out);
          return ERROR_SUCCESS;
        }
 
        directory = Path.Combine(Environment.CurrentDirectory, directory);
        break;
 
      case 2:
        directory = args[0];
        name = args[1];
        break;
 
      default:
        Console.Error.WriteLine("Error: invalid number of parameters.");
        Usage(Console.Error);
        return ERROR_INVALID_PARAMETER;
    }
 
    // Create the Shell object and get the specified folder.
    ShellClass shell = new ShellClass();
    Folder folder = shell.NameSpace(directory);
    if (folder != null)
    {
      if (name != null)
      {
        FolderItem item = folder.ParseName(name);
        if (item != null)
        {
          DisplayLink(item);
        }
        else
        {
          Console.Error.WriteLine("Error: file not found.");
          return ERROR_FILE_NOT_FOUND;
        }
      }
      else
      {
        foreach (FolderItem item in folder.Items())
        {
          DisplayLink(item);
        }
      }
    }
    else
    {
      Console.Error.WriteLine("Error: directory not found.");
      return ERROR_PATH_NOT_FOUND;
    }
 
    return ERROR_SUCCESS;
  }
 
  static void DisplayLink(FolderItem item)
  {
    IShellLinkDual link = null;
    if (item != null)
    {
      if (item.IsLink)
      {
        link = (IShellLinkDual)item.GetLink;
        if (link != null)
        {
          Console.WriteLine(OUTPUT_FORMAT, item.Name, link.Path);
        }
      }
    }
  }
 
  static void Usage(TextWriter writer)
  {
    if (writer != null)
    {
      writer.WriteLine("Usage: {0} [directory [name]]",
        Path.GetFileName(Environment.GetCommandLineArgs()[0]));
      writer.WriteLine();
      writer.WriteLine("\tdirectory Path to a directory.");
      writer.WriteLine("\t          If not specified, the current directory is used.");
      writer.WriteLine("\tname      The name of a single shell link.");
      writer.WriteLine("\t          If not specified, all links are displayed.");
    }
  }
}


This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft

[My Articles] [My Blog]
QuestionDatabase query Pin
ybasha5-Oct-05 21:39
ybasha5-Oct-05 21:39 
AnswerRe: Database query Pin
Heath Stewart6-Oct-05 6:43
protectorHeath Stewart6-Oct-05 6:43 
QuestionSearching for a string value Pin
Brendan Vogt5-Oct-05 20:37
Brendan Vogt5-Oct-05 20:37 
AnswerRe: Searching for a string value Pin
S. Senthil Kumar5-Oct-05 20:45
S. Senthil Kumar5-Oct-05 20:45 
GeneralRe: Searching for a string value Pin
Brendan Vogt5-Oct-05 21:01
Brendan Vogt5-Oct-05 21:01 
GeneralRe: Searching for a string value Pin
S. Senthil Kumar5-Oct-05 21:12
S. Senthil Kumar5-Oct-05 21:12 
GeneralRe: Searching for a string value Pin
Brendan Vogt5-Oct-05 21:55
Brendan Vogt5-Oct-05 21:55 
AnswerRe: Searching for a string value Pin
Guffa5-Oct-05 23:01
Guffa5-Oct-05 23:01 
GeneralRe: Searching for a string value Pin
Brendan Vogt5-Oct-05 23:10
Brendan Vogt5-Oct-05 23:10 
AnswerRe: Searching for a string value Pin
Guffa6-Oct-05 0:22
Guffa6-Oct-05 0:22 
GeneralRe: Searching for a string value Pin
Brendan Vogt6-Oct-05 0:41
Brendan Vogt6-Oct-05 0:41 
GeneralRe: Searching for a string value Pin
Guffa6-Oct-05 1:20
Guffa6-Oct-05 1:20 
QuestionSetup starts after installation again Pin
Ariadne5-Oct-05 20:31
Ariadne5-Oct-05 20:31 
AnswerRe: Setup starts after installation again (minor bug) Pin
Ariadne6-Oct-05 20:14
Ariadne6-Oct-05 20:14 
QuestionSockets in C# Pin
Thoughthopper5-Oct-05 20:04
Thoughthopper5-Oct-05 20:04 
Questionsetup problem Pin
shashank veerkar5-Oct-05 19:40
shashank veerkar5-Oct-05 19:40 
AnswerRe: setup problem Pin
Ariadne5-Oct-05 20:49
Ariadne5-Oct-05 20:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.