This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- using static .Net functions
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 12, 2012
06:23 AM
using static .Net functions
Please can someone advise me if, and if so, how to call a static .Net method from installscript?
I want to use Dns.GetHostName();
I presume the DotNetCoCreateObject does what is says and creates an object so wouldn't work in this case?
I'm guessing I'll have to wrap the call in one of my own .net objects
Thanks
I want to use Dns.GetHostName();
I presume the DotNetCoCreateObject does what is says and creates an object so wouldn't work in this case?
I'm guessing I'll have to wrap the call in one of my own .net objects
Thanks
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 10, 2014
04:05 AM
Com does not allow static methods to be called so the method you call from InstallScript will need to be non-static.
http://msdn.microsoft.com/en-us/library/ms182198.aspx
http://msdn.microsoft.com/en-us/library/ms182198.aspx
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 23, 2014
09:52 PM
First you compile your class as a DLL with COM visible.
If you are using a .NET class you should be able to use DotNetCoCreateObject to create an object within your installscript.
If it is C or C++ then you will need to load it with UseDLL(someFile.DLL), then call the method, and then UnUseDLL(someFile.DLL). You also need to prototype the methods in your script.
example:
If all you want is to get the host name of the machine you can do this without any custom libraries.
There are a couple ways to do this from installscript:
1. Use the environment variable
Or
2. Get the value from the registry
If you need the fully qualified host.domain value you can also get the domain from the same key
Then append the domain to the host name only if it actually has a domain value:
If you are using a .NET class you should be able to use DotNetCoCreateObject to create an object within your installscript.
If it is C or C++ then you will need to load it with UseDLL(someFile.DLL), then call the method, and then UnUseDLL(someFile.DLL). You also need to prototype the methods in your script.
example:
prototype stdcall void ClassName.MethodName(BYREF WSTRING);
If all you want is to get the host name of the machine you can do this without any custom libraries.
There are a couple ways to do this from installscript:
1. Use the environment variable
GetEnvVar("COMPUTERNAME", szHost);
Or
2. Get the value from the registry
RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
szKey = "SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters";
RegDBGetKeyValueEx(szKey,"Hostname", nType, szHost, nSize);
If you need the fully qualified host.domain value you can also get the domain from the same key
RegDBGetKeyValueEx(szKey,"Domain", nType, szDomain, nSize);
Then append the domain to the host name only if it actually has a domain value:
if (szDomain != "") then
szFQDN = szHost + "." + szDomain;
else
szFQDN = szHost;
endif;