Archive

Posts Tagged ‘spaces’

How to Send E-mail With the Default E-mail Client

October 19th, 2007 m3Rlin No comments

You may want to allow users to send you back feedback. You can either send it directly to your site via sockets or send the user to your website. What if you don’t have a website? No feedback? Yeah, right. Just have them send it to you by e-mail.

You can not send spaces in URLs, you have to convert them first. Example: if the subject were to be ‘Bug Report!’ then you should put %20 instead of the space character – ‘Bug%20Report!’. %20 is the ASCII value for space.

In this example MemoBugText is the memo in which the user describes the bug, ‘bugreports@youremail.com’ is your e-mail address and ‘Bug Report’ is the subject of that e-mail.

uses
  ShellAPI, Windows;

// For more information on ShellExecute() check out our tip
// "How to run programs and execute documents, mailto links and URLs" in the Windows category
ShellExecute(0, 'open', PChar('mailto:bugreports@youremail.com?subject=Bug%20Report&Body=' + MemoBugText.Text), nil, nil, SW_SHOWNORMAL);

How to Add a Context Menu Item to Windows Explorer

December 15th, 1999 m3Rlin 1 comment

To add a context menu item to Windows Explorer you have create a few entries in the system Registry. First you have to get the file type’s name, add the context menu item and add then the command line. Besides files you can add context menus to drives or folders.<br>
Special extensions:<br>
- <i>.drive</i> – drives.<br>
- <i>.folder</i> – folders.
<pre>
<b>uses</b>
Registry;

<b> </b>var
sTypeName: <b>string</b>;
<b>begin
with</b> TRegistry.Create <b>do
try</b>
RootKey := HKEY_CLASSES_ROOT;
<i>{ Set the extension you want. Include the ‘.’ character }</i>
OpenKey(‘.Extension’, True);
<i>{ Get file type name }</i>
sTypeName := ReadString(”);
CloseKey;

<i>(* Create explorer extension.
*
* Instead of ‘Open’ put whatever you want.
*)</i>
OpenKey(” + sTypeName + ‘ShellOpen’, True);
<i>{ The context menu item }</i>
WriteString(”, ‘Open in my application’);
CloseKey;

OpenKey(” + sTypeName + ‘ShellOpenCommand’, True);
<i>(* The commandline. Enter all the commandline options you need.
* Remember to use quotes for long file names with spaces. Even if your
* application’s filename doesn’t contain any spaces the folder that
* it’s in may contain them.
*
* %1 – is the selected file’s name.
*)</i>
WriteString(”, ‘”‘ + Application.ExeName + ‘” “%1″‘);
CloseKey;

<i>(* Repeat this for every file type you want to add a context menu to.
* For this operation you may want to use a for loop and a constat
* string array with the file extensions.
*)</i>
<b>finally</b>
Free;
<b>end</b>;
<b>end</b>;
</pre>