Difference between revisions of "PlugIn Development:GameEx Initialize Function"

From Spesoft/GameEx Wiki
Jump to navigation Jump to search
Line 27: Line 27:


=== <span class="plugin_text_fx">C#</span> ===
=== <span class="plugin_text_fx">C#</span> ===
---
----
==== <span style="color:purple;">Structure</span> ====
==== <span style="color:purple;">Structure</span> ====
<pre class="code_block_struct">
<pre class="code_block_struct">

Revision as of 23:53, 27 April 2014

This function is called when GameEx initializes.
Using this function call, you can run code to do various things, like set up your log files or load your settings.

Returns

This function returns a BOOLEAN value.

Return Values

Return TRUE to initialize your plugin.
Return FALSE and GameEx will not initialize your plugin.

Code Examples

The code samples below outline the syntax needed to process the call in the PlugIn.dll file within the template.

VB.NET


Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure GameExInfo
    Public GameExVersion As String
End Structure

Function

Public Function Initialize(ByVal InfoPtr As IntPtr) As Boolean
     Dim Info As GameExInfo = DirectCast(Marshal.PtrToStructure(InfoPtr, GetType(GameExInfo)), GameExInfo))
     'This will output the current version of GameEx:
     Dim GameEx_Version As String = Info.GameExVersion
     Return True
End Function

C#


Structure

[ StructLayout( LayoutKind.Sequential )]
public struct GameExInfo
{
     public string GameExVersion;
}

Function

public bool Initialize(IntPtr InfoPtr)
{
     GameExInfo Info = (GameExInfo) Marshal.PtrToStructure(InfoPtr, typeof(GameExInfo));
     //This will output the current version of GameEx as a string:
     string GameEx_Version = Info.GameExVersion;
     return true;
}