Hi. This is a pretty straightforward question. The following snippet
of VB.NET code will compile and perform the task you're looking for.
Compile this to "stripprotocol.exe" and place it in C:\WINDOWS:
stripprotocol.vb:
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Public Module Test
Public Sub Main( args as String() )
If args.Length <> 1 Then
MessageBox.Show( "Need exactly one argument" )
Return
End If
If Not args( 0 ).StartsWith( "note:" )
MessageBox.Show( "Argument must start with 'note:'" )
Return
End If
' 5 is the length of the string "note:"
args( 0 ) = args( 0 ).Substring( 5 )
' Uncomment to see what gets passed to the program
' MessageBox.Show( args( 0 ) )
System.Diagnostics.Process.Start( "notepad.exe", args( 0 ) )
End Sub
End Module
Use the following registry settings to run it:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\note]
@="URL:Note Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\note\DefaultIcon]
@="notepad.exe"
[HKEY_CLASSES_ROOT\note\shell]
[HKEY_CLASSES_ROOT\note\shell\open]
[HKEY_CLASSES_ROOT\note\shell\open\command]
@="C:\\windows\\stripprotocol.exe \"%1\""
^-- Note that if you are entering this in the registry by hand, this
should be: C:\windows\stripprotocol.exe "%1"
If you have any questions, feel free to ask. |
Request for Answer Clarification by
bacteriaa-ga
on
26 Aug 2003 11:19 PDT
Thanks for your quick response.
However I tried to compile the code and I get the following error
<b> 'Process' is not a member of 'Diagnostics' </b>
I have all of these in the Imports:
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports System
Imports System.Diagnostics
Imports System.ComponentModel
But still doesnt help.
|
Clarification of Answer by
mmastrac-ga
on
28 Aug 2003 08:47 PDT
Do you have a reference to the "System" and "System.Windows.Forms"
dlls in your project? From your message, it sounds like you might
not.
If you are compiling from the command line, this would be the command:
C:\>vbc stripprotocol.vb /r:System.Windows.Forms.dll /r:System.dll
Let me know if you need any additional help.
|
Request for Answer Clarification by
bacteriaa-ga
on
28 Aug 2003 09:14 PDT
I created a new project in VS.Net and entered the code.
Gives me the same error message.
I have included the System.Windows.Forms namespace.
|
Request for Answer Clarification by
bacteriaa-ga
on
28 Aug 2003 09:45 PDT
I compiled through the cmd prompt and it worked. Sorry abt that. I
dont know why VS.Net wouldnt do it. But anyway, as long as it works.
But when run the command
note: c:\test.txt
It opens the file fine but gives another error message box saying the
file 'note: c:\test.txt' could not be found.
|
Clarification of Answer by
mmastrac-ga
on
29 Aug 2003 11:34 PDT
Odd. I tested exactly what I've posted here and it seems to work
fine. Can you verify that your registry settings are correct? The
most important item would be that the command looks like this in
REGEDIT (including the quotes):
C:\somepath\stripprotocol.exe "%1"
Are you entering the URL as "note:C:\test.txt" or "note: C:\text.txt"?
Note the extra space. I tried both and they seem to work here,
however. It could possibly be a windows version issue, though.
Where is the error message coming from? Is it from the code I've
given you, or is notepad saying that it can't find the file?
|