Solved

Can you determine a procedure's address from its name?

Posted on 2004-09-27
4
170 Views
Last Modified: 2010-04-23
I am interested in using a method's name (ie MyFunc) to find its address. I know you can use CallByName to actually call the function, but I just want to get its address. I have a delegate and I want to assign it the AddressOf "MyFunc".
0
Comment
Question by:BASESLydia
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 125 total points
ID: 12159664
u can use the GetAssemblyByName method

Imports System
Imports System.Reflection
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic

Public Class AssemblyName_GetAssemblyName
   
   Public Shared Sub Main()
     

      ' Get the type of 'System.Object'.
      Dim myType As Type = GetType(System.Object)
     
      ' Get the path of 'System.dll'.
      Dim system As String = Regex.Replace(myType.Assembly.CodeBase, "mscorlib.dll", "System.dll")
      system = Regex.Replace(system, "file:///", "")
     
      ' Get the assembly information and display to the console.
      Dim myAssemblyName As AssemblyName = AssemblyName.GetAssemblyName(system)
      Console.WriteLine(ControlChars.Cr + "Displaying the assembly information of 'System.dll'" + ControlChars.Cr)
      Console.WriteLine(myAssemblyName.ToString())
   End Sub 'Main
End Class 'AssemblyName_GetAssemblyName

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12170767
What's wrong with AddressOf?

Bob
0
 
LVL 1

Author Comment

by:BASESLydia
ID: 12170815
Unless I am using it wrong, AddressOf requires the function name be typed at runtime, you cannot use a string as a parameter. I would like to load the string name from a database and get the address from it at a runtime.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12170838
Aaah, yes, that one again.  Good luck!

Bob
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now