Creating shortcuts (C code help)

BlitzMax Forums/BlitzMax Programming/Creating shortcuts (C code help)

Drackbolt(Posted 2010) [#1]
Hello,
I'm a rank newbie in C, but I think I need to make use of it to create shortcuts programmatically. I've found the following code in C online (specifically, here):
private WshShellClass WshShell;
using IWshRuntimeLibrary;

// Create a new instance of WshShellClass

WshShell = new WshShellClass();

// Create the shortcut

IWshRuntimeLibrary.IWshShortcut MyShortcut;

// Choose the path for the shortcut

MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@...");

// Where the shortcut should point to

MyShortcut.TargetPath = Application.ExecutablePath;

// Description for the shortcut

MyShortcut.Description = "Launch My Application";

// Location for the shortcut's icon

MyShortcut.IconLocation = Application.StartupPath + @"\App.ico";

// Create the shortcut at the given path

MyShortcut.Save();

I have MinGW set up and everything, and I've read up a bit on the C tutorials, but I can't figure out how to get this code to compile or otherwise modify it to work in BlitzMax. I'd appreciate any help here. The ultimate goal is to create a function in Blitzmax with arguments to create a shortcut in Windows with location, description, name and icon specified.


plash(Posted 2010) [#2]
That's not C.


Drackbolt(Posted 2010) [#3]
lol... Um, what is it then? :P And if you're feeling helpful, what would the C code be like?


Czar Flavius(Posted 2010) [#4]
That's C#, fyi.

Here are some links:
http://www.codeproject.com/KB/shell/create_shortcut.aspx
http://www.codeproject.com/KB/files/SimpleWayToCreateShortcut.aspx
http://answers.yahoo.com/question/index?qid=20060709204254AArw6u6
http://www.devmaster.net/forums/archive/index.php/t-7297.html

I'm afraid you're on your own with them, though. You're about to learn why anything with "C" in the name sucks.


Dabhand(Posted 2010) [#5]
http://www.codeproject.com/KB/files/SimpleWayToCreateShortcut.aspx

Theres a link in the page above for a more in-depth way of doing it too.

Dabz


Drackbolt(Posted 2010) [#6]
Thanks guys! I didn't realize C and C# would be so distinctively different. So is C# not usable by Blitzmax?


Czar Flavius(Posted 2010) [#7]
Only C and C++.


Gabriel(Posted 2010) [#8]
It's not just a question of language. That code makes heavy use of the .Net framework, which makes using it in BMax a challenge.

Try this C example. I don't have BMax, MinGW, etc all set up on my Mac, but hopefully someone else can help with that. Or try looking at the modules which come with BlitzMax, as they use C code extensively.

http://www.codeproject.com/KB/winsdk/makelink.aspx


Jesse(Posted 2010) [#9]
I don't know if this is any help to you but a while back I was trying to learn to decode the lnk files. I found some information in the net but while I was trying to access the page where I got the information from, found out it no longer existed. I do have the pdf file. If you are interested in it I can email it to you. the guy that was decoding the link got most of it working but was unable to decode some stuff. I crated a lnk reader program but is really a simple attempt to see if it would be of any use to me.
the code follows:


note:
also I don't know if it works with vista and windows 7 the code is a few years old.