Hi,
In C/C++
LONG 32-bit signed integer.
In C#
long Signed 64-bit integer
Therefore we must use 32-bit type (like int) for parameters :
year, month, day, hour, minutes, seconds, milliseconds.
DllImport declaration of StarBurn_UDF_CreateEx() must be something like that:
Code:
[DllImport("StarBurn.dll", CharSet = CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
public static extern EXCEPTION_NUMBER StarBurn_UDF_CreateEx(
uint UDFRoot,
uint ISO9660UDFBridgeRootVideo,
uint ISO9660UDFBridgeRootAudio,
out UDF_CONTROL_BLOCK PUDF_CONTROL_BLOCK,
IntPtr ExceptionText,
int ExceptionTextSize,
out uint SystemError,
[MarshalAs(UnmanagedType.LPStr)]
String VolumeLabel,
[MarshalAs(UnmanagedType.LPStr)]
String PublisherPreparerName,
[MarshalAs(UnmanagedType.LPStr)]
String MyApplicationName,
int year,
int month,
int day,
int hour,
int minutes,
int seconds,
int milliseconds);
mbat wrote:
Hi,
I'm trying to import some StarBurn api to build (and burn) an UDF image, but I got the following error from VS2005:
Quote:
A call to PInvoke function 'StarBurnWrapper!StarBurnWrapper.Dll::StarBurn_UDF_CreateEx' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
My imports are the the following:
Code:
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct UDF_CONTROL_BLOCK
{
public int Head;
public int SystemStructures;
public int Tail;
public int Body;
}
[DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
public static extern int StarBurn_UDF_GetNodeObject(int parent);
[DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
public static extern EXCEPTION_NUMBER StarBurn_UDF_Add(StringBuilder ExceptionText, int ExceptionTextSize,
ref int SystemError, StringBuilder DirectoryOrFileAbsolutePathAndName,
StringBuilder DirectoryOrFileNewName, int parent, ref int newChild);
[DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
public static extern EXCEPTION_NUMBER StarBurn_UDF_CreateEx(int UDFRoot, int ISO9660UDFBridgeRootVideo,
int ISO9660UDFBridgeRootAudio, ref UDF_CONTROL_BLOCK PUDF_CONTROL_BLOCK,
StringBuilder ExceptionText, int ExceptionTextSize,
ref int SystemError, StringBuilder VolumeLabel, StringBuilder PublisherPreparerName,
StringBuilder ApplicationName, long year, long month, long day, long hour, long minutes,
long seconds, long milliseconds);
The problem raises calling StarBurn_UDF_CreateEx in this piece of code:
Code:
int root = 0;
int child = 0;
StringBuilder absPath = new StringBuilder("c:\\burn\\eclipse.zip");
StringBuilder newPath = new StringBuilder("eclipse.zip");
ErrorCode = Dll.StarBurn_UDF_Add(ExceptionText, 1024, ref SystemError, null, null, 0, ref root);
ErrorCode = Dll.StarBurn_UDF_Add(ExceptionText, 1024, ref SystemError, absPath, newPath, root, ref child);
StringBuilder vLabel = new StringBuilder("TEST", 10);
StringBuilder pubName = new StringBuilder("Test", 10);
StringBuilder AppName = new StringBuilder("wrapper", 10);
//UDF_Control_Block = new UDF_CONTROL_BLOCK();
int node = Dll.StarBurn_UDF_GetNodeObject(root);
UDF_Control_Block.Body = 0;
UDF_Control_Block.Head = 0;
UDF_Control_Block.SystemStructures = 0;
UDF_Control_Block.Tail = 0;
int video = 0;
int audio = 0;
ErrorCode = Dll.StarBurn_UDF_CreateEx(node, video, audio, ref UDF_Control_Block,
ExceptionText, 1024, ref SystemError, vLabel, pubName, AppName,
2007, 1, 26, 23, 14, 12, 2);
thanks in advance,
Massimo.