|
-
Mar 4th, 2006, 12:45 AM
#1
[RESOLVED] Get the GUID of the Application
How can I get the GUID of an application?
I found this code on the net:
VB Code:
System.Runtime.InteropServices.GuidAttribute guid = (System.Runtime.InteropServices.GuidAttribute)System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(System.Runtime.InteropServices.GuidAttribute, false);
guid.ToString();
The space is for GetCustomAttributes(). No idea why vBull breaks up a line in code tags via HTML so it inserts a space
However, it gives me an error stating GetCustomAttributes requires a Type in the first parameter. I thought I was giving it a type?
Is there a better way to do this or what is the problem with my code?
Also, if I put this code into a DLL, will it give me the GUID of my DLL or the Application calling the DLL?
Last edited by Kasracer; Mar 4th, 2006 at 12:49 AM.
-
Mar 4th, 2006, 07:28 PM
#2
Re: Get the GUID of the Application
It needs an instance of the Type class, which means you need to pass it typeof(System.Runtime.InteropServices.GuidAttribute).
-
Mar 4th, 2006, 07:34 PM
#3
Re: Get the GUID of the Application
If I'm not mistaken, the assembly itself gets the GUID of the type it has. Have you checked the Type.Guid property?
VB Code:
Dim myType As Type = GetType(YOURCLASSNAME)
' Get the object of the Guid.
Dim myGuid As Guid = CType(myType.GUID, Guid)
Console.WriteLine(("The name of the class is " + myType.ToString()))
Console.WriteLine(("The ClassId of MyClass is " + myType.GUID.ToString()))
That's from MSDN. Sure you can convert it.
-
Mar 5th, 2006, 02:55 PM
#4
Re: Get the GUID of the Application
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|