SetDLLName

[Top]  [Chapter]  [Previous]  [Next]

This is not required for the demo - but for a released application you need to specify the DLL name using the static function WPDLLInt1.SetDLLName(string)- this tells the wrapper the location of the DLL.

 

This procedure should be called before any text control is created, a good place is the Main() function or, in VB.NET, Form.New().

 

Once the DLL was loaded the name cannot be changed anymore.

 

It is possible to read the name from the registry: Specify the path to the registry key (type string) preceeded by {hkcu} to use HKEY_CURRENT_USER, or {hklm} to use HKEY_LOCAL_MACHINE.

 

Example:

"{hkcu}Software\MyCompany\TextDynamic\path" will load the name from the string property path under HKEY_CURRENT_USER\Software\MyCompany\TextDynamic.

 

[STAThread]

static void Main()

{

   WPDLLInt.SetDLLName("{hkcu}Software\\MyCompany\\TextDynamic\\path");

   Application.Run(new WinForm());

}

 

Note: The key Software\WPCubed\TextDynamic\path is created by the WPToolsDLL setup script and must not be used in your application. We use this string as default setting inside the C# code.

 

You can also store the DLL in same directory as the assembly and use this code to load it.

 

// look in same directory as assembly

Assembly TextDynamicAssembly = Assembly.GetAssembly(typeof(WPDLLInt));

string TextDynamicDLL = Path.GetDirectoryName(TextDynamicAssembly.Location) + "\\WPTextDLL01.dll";

// If not existent there look in same directory as executable

if (!File.Exists(TextDynamicDLL))

{

   TextDynamicDLL = Path.GetDirectoryName(Application.ExecutablePath) + "\\WPTextDLL01.dll";

}

// Set the DLL name (prelaod the DLL)

WPDynamic.WPDLLInt.SetDLLName(TextDynamicDLL);

 

// later

InitializeComponent();

 

 

 


[setdllnameex.htm]    Copyright © 2007 by WPCubed GmbH