Parsing DLL in VB.Net
-
I am trying to "Register an Application to a URL Protocol" (Refer to: http://msdn.microsoft.com/workshop/networking/pluggable/overview/appendix_a.asp?frame=true ) I ran the registry script (provided in the article): [HKEY_CLASSES_ROOT] [note] (Default) = "URL:Note Protocol" URL Protocol = "" [DefaultIcon] (Default) = "notepad.exe" [shell] [open] [command] (Default) = "c:\windows\notepad.exe %1" However, this code does not work as quoted. Everytime I execute the command "note:c:\myfile.txt", the notepad application opens up but an error message pops up saying "Could not find the file note:c:\myfile.txt ". The registry code here actually takes the complete command as an argument for itself. I looked into some examples in the registry if they share this problem. And they seem to. However to counter this, they have an additional dll (usually url.dll) which strips off the 'note:' (or whatever the command is) in the total command and sends the rest as an parameter. My question is how can I write such a DLL which will take an input string and return its substring (Need code). For e.g. If I execute > notepad MyStripper.dll note:c:\note.txt the dll should strip "note:c:\note.txt" and just send "c:\note.txt" as an argument to the notepad application. Thank u in advance. Would prefer code solution in VB.Net
-
Answer:
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.
bacteriaa-ga at Google Answers Visit the source
Related Q & A:
- Where To Download Dll Files?Best solution by Quora
- How to Convert Code from VB to C++?Best solution by Stack Overflow
- How Can I use .net dll in C program?Best solution by Stack Overflow
- How to save from DatagridView to Database VB.NET?Best solution by Stack Overflow
- What is the best language for HTML parsing and web scraping?Best solution by Quora
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.