I am calling an unmanaged DLL like follows in a Class wrapper.
namespace blah
{
[DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint",
CallingConvention=CallingConvention.ThisCall]
public static extern void blahFn(out long blah, out long blah2);
class sealed ClassBlah
{
private ClassBlah()
{
}
}
}
Why have I to call this with the CallingConvention of ThisCall, its just
normal "C" functions in a DLL. Why wont StdCall work?
What happens with other calling conventions is that the out parameters are
NOT set, yet with ThisCall, they are set ok, or appear to be. I find it odd.
Thanks 12 2135
Mr. Tickle,
What is the declaration of the original function? If it takes a
pointer, then you should be using "ref" for the parameters, and not out.
Also, does the function take a 64-bit integer? Long in C is a 32-bit
integer, where in .NET it is a 64-bit integer.
The STDCALL mechanism should work if you are using it.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message
news:Oo**************@TK2MSFTNGP09.phx.gbl... I am calling an unmanaged DLL like follows in a Class wrapper.
namespace blah { [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", CallingConvention=CallingConvention.ThisCall] public static extern void blahFn(out long blah, out long blah2);
class sealed ClassBlah { private ClassBlah() { }
} }
Why have I to call this with the CallingConvention of ThisCall, its just normal "C" functions in a DLL. Why wont StdCall work?
What happens with other calling conventions is that the out parameters are NOT set, yet with ThisCall, they are set ok, or appear to be. I find it
odd.
Thanks
Nop, I tried ref and it doesnt help, the only way i can get it to return
values is with thiscall.
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:#p**************@TK2MSFTNGP11.phx.gbl... Mr. Tickle,
What is the declaration of the original function? If it takes a pointer, then you should be using "ref" for the parameters, and not out. Also, does the function take a 64-bit integer? Long in C is a 32-bit integer, where in .NET it is a 64-bit integer.
The STDCALL mechanism should work if you are using it.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:Oo**************@TK2MSFTNGP09.phx.gbl... I am calling an unmanaged DLL like follows in a Class wrapper.
namespace blah { [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", CallingConvention=CallingConvention.ThisCall] public static extern void blahFn(out long blah, out long blah2);
class sealed ClassBlah { private ClassBlah() { }
} }
Why have I to call this with the CallingConvention of ThisCall, its
just normal "C" functions in a DLL. Why wont StdCall work?
What happens with other calling conventions is that the out parameters
are NOT set, yet with ThisCall, they are set ok, or appear to be. I find it odd.
Thanks
So i should use Int32 for the parameters instead of long?
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:#p**************@TK2MSFTNGP11.phx.gbl... Mr. Tickle,
What is the declaration of the original function? If it takes a pointer, then you should be using "ref" for the parameters, and not out. Also, does the function take a 64-bit integer? Long in C is a 32-bit integer, where in .NET it is a 64-bit integer.
The STDCALL mechanism should work if you are using it.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:Oo**************@TK2MSFTNGP09.phx.gbl... I am calling an unmanaged DLL like follows in a Class wrapper.
namespace blah { [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", CallingConvention=CallingConvention.ThisCall] public static extern void blahFn(out long blah, out long blah2);
class sealed ClassBlah { private ClassBlah() { }
} }
Why have I to call this with the CallingConvention of ThisCall, its
just normal "C" functions in a DLL. Why wont StdCall work?
What happens with other calling conventions is that the out parameters
are NOT set, yet with ThisCall, they are set ok, or appear to be. I find it odd.
Thanks
I also have a problem with "ref" paramaters, it says they need to be
assigned to before used
Yet i have them used as "ref" in dll extern calls and checked for non NULL
after yet it complains for non assignment so i use a local copy.
Isnt it smart enough to detect that its being assinged in an extern dll call
as declared in DllImport?
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:#p**************@TK2MSFTNGP11.phx.gbl... Mr. Tickle,
What is the declaration of the original function? If it takes a pointer, then you should be using "ref" for the parameters, and not out. Also, does the function take a 64-bit integer? Long in C is a 32-bit integer, where in .NET it is a 64-bit integer.
The STDCALL mechanism should work if you are using it.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:Oo**************@TK2MSFTNGP09.phx.gbl... I am calling an unmanaged DLL like follows in a Class wrapper.
namespace blah { [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", CallingConvention=CallingConvention.ThisCall] public static extern void blahFn(out long blah, out long blah2);
class sealed ClassBlah { private ClassBlah() { }
} }
Why have I to call this with the CallingConvention of ThisCall, its
just normal "C" functions in a DLL. Why wont StdCall work?
What happens with other calling conventions is that the out parameters
are NOT set, yet with ThisCall, they are set ok, or appear to be. I find it odd.
Thanks
i mean "out" oops.
ref in the same dll wrapper still gets the output but only with thiscall
convention.
"Mr.Tickle" <Mr******@mrmen.com> wrote in message
news:OQ**************@TK2MSFTNGP09.phx.gbl... I also have a problem with "ref" paramaters, it says they need to be assigned to before used
Yet i have them used as "ref" in dll extern calls and checked for non NULL after yet it complains for non assignment so i use a local copy.
Isnt it smart enough to detect that its being assinged in an extern dll
call as declared in DllImport?
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com>
wrote in message news:#p**************@TK2MSFTNGP11.phx.gbl... Mr. Tickle,
What is the declaration of the original function? If it takes a pointer, then you should be using "ref" for the parameters, and not out. Also, does the function take a 64-bit integer? Long in C is a 32-bit integer, where in .NET it is a 64-bit integer.
The STDCALL mechanism should work if you are using it.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:Oo**************@TK2MSFTNGP09.phx.gbl... I am calling an unmanaged DLL like follows in a Class wrapper.
namespace blah { [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", CallingConvention=CallingConvention.ThisCall] public static extern void blahFn(out long blah, out long blah2);
class sealed ClassBlah { private ClassBlah() { }
} }
Why have I to call this with the CallingConvention of ThisCall, its just normal "C" functions in a DLL. Why wont StdCall work?
What happens with other calling conventions is that the out parameters are NOT set, yet with ThisCall, they are set ok, or appear to be. I find
it odd.
Thanks
If you could post the original function declaration, it would help
tremendously.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl... i mean "out" oops.
ref in the same dll wrapper still gets the output but only with thiscall convention.
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:OQ**************@TK2MSFTNGP09.phx.gbl... I also have a problem with "ref" paramaters, it says they need to be assigned to before used
Yet i have them used as "ref" in dll extern calls and checked for non
NULL after yet it complains for non assignment so i use a local copy.
Isnt it smart enough to detect that its being assinged in an extern dll call as declared in DllImport?
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote in message news:#p**************@TK2MSFTNGP11.phx.gbl... Mr. Tickle,
What is the declaration of the original function? If it takes a pointer, then you should be using "ref" for the parameters, and not
out. Also, does the function take a 64-bit integer? Long in C is a 32-bit integer, where in .NET it is a 64-bit integer.
The STDCALL mechanism should work if you are using it.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:Oo**************@TK2MSFTNGP09.phx.gbl... > I am calling an unmanaged DLL like follows in a Class wrapper. > > namespace blah > { > [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", > CallingConvention=CallingConvention.ThisCall] > public static extern void blahFn(out long blah, out long blah2); > > class sealed ClassBlah > { > private ClassBlah() > { > } > > } > } > > Why have I to call this with the CallingConvention of ThisCall, its just > normal "C" functions in a DLL. Why wont StdCall work? > > What happens with other calling conventions is that the out
parameters are > NOT set, yet with ThisCall, they are set ok, or appear to be. I find it odd. > > > > Thanks > >
It would but I dont have it, its in a dll i have to call into. Not mine.
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:OB**************@TK2MSFTNGP11.phx.gbl... If you could post the original function declaration, it would help tremendously.
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:e6**************@TK2MSFTNGP09.phx.gbl... i mean "out" oops.
ref in the same dll wrapper still gets the output but only with thiscall convention.
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:OQ**************@TK2MSFTNGP09.phx.gbl... I also have a problem with "ref" paramaters, it says they need to be assigned to before used
Yet i have them used as "ref" in dll extern calls and checked for non NULL after yet it complains for non assignment so i use a local copy.
Isnt it smart enough to detect that its being assinged in an extern
dll call as declared in DllImport?
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote in message news:#p**************@TK2MSFTNGP11.phx.gbl... > Mr. Tickle, > > What is the declaration of the original function? If it takes a > pointer, then you should be using "ref" for the parameters, and not out. > Also, does the function take a 64-bit integer? Long in C is a
32-bit > integer, where in .NET it is a 64-bit integer. > > The STDCALL mechanism should work if you are using it. > > Hope this helps. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - ni**************@exisconsulting.com > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > news:Oo**************@TK2MSFTNGP09.phx.gbl... > > I am calling an unmanaged DLL like follows in a Class wrapper. > > > > namespace blah > > { > > [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", > > CallingConvention=CallingConvention.ThisCall] > > public static extern void blahFn(out long blah, out long blah2); > > > > class sealed ClassBlah > > { > > private ClassBlah() > > { > > } > > > > } > > } > > > > Why have I to call this with the CallingConvention of ThisCall,
its just > > normal "C" functions in a DLL. Why wont StdCall work? > > > > What happens with other calling conventions is that the out parameters are > > NOT set, yet with ThisCall, they are set ok, or appear to be. I
find it > odd. > > > > > > > > Thanks > > > > > >
typedef SOME_ID long
SOME_ID someFn(SOME_ID* someIDhere, SOME_ID* someIDhere2, SOME_ID*
someIDhere3);
something like that.
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:OB**************@TK2MSFTNGP11.phx.gbl... If you could post the original function declaration, it would help tremendously.
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:e6**************@TK2MSFTNGP09.phx.gbl... i mean "out" oops.
ref in the same dll wrapper still gets the output but only with thiscall convention.
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:OQ**************@TK2MSFTNGP09.phx.gbl... I also have a problem with "ref" paramaters, it says they need to be assigned to before used
Yet i have them used as "ref" in dll extern calls and checked for non NULL after yet it complains for non assignment so i use a local copy.
Isnt it smart enough to detect that its being assinged in an extern
dll call as declared in DllImport?
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote in message news:#p**************@TK2MSFTNGP11.phx.gbl... > Mr. Tickle, > > What is the declaration of the original function? If it takes a > pointer, then you should be using "ref" for the parameters, and not out. > Also, does the function take a 64-bit integer? Long in C is a
32-bit > integer, where in .NET it is a 64-bit integer. > > The STDCALL mechanism should work if you are using it. > > Hope this helps. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - ni**************@exisconsulting.com > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > news:Oo**************@TK2MSFTNGP09.phx.gbl... > > I am calling an unmanaged DLL like follows in a Class wrapper. > > > > namespace blah > > { > > [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", > > CallingConvention=CallingConvention.ThisCall] > > public static extern void blahFn(out long blah, out long blah2); > > > > class sealed ClassBlah > > { > > private ClassBlah() > > { > > } > > > > } > > } > > > > Why have I to call this with the CallingConvention of ThisCall,
its just > > normal "C" functions in a DLL. Why wont StdCall work? > > > > What happens with other calling conventions is that the out parameters are > > NOT set, yet with ThisCall, they are set ok, or appear to be. I
find it > odd. > > > > > > > > Thanks > > > > > >
Mr.Tickle,
In this case, you definitely want to use the int type, and pass it by
reference. Your declaration should look like this:
[DllImport("somedll.dll")]
public static extern int someFn(ref int someIDhere, ref int someIDhere2, ref
int someIDhere3);
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... typedef SOME_ID long
SOME_ID someFn(SOME_ID* someIDhere, SOME_ID* someIDhere2, SOME_ID* someIDhere3);
something like that.
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com>
wrote in message news:OB**************@TK2MSFTNGP11.phx.gbl... If you could post the original function declaration, it would help tremendously.
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:e6**************@TK2MSFTNGP09.phx.gbl... i mean "out" oops.
ref in the same dll wrapper still gets the output but only with
thiscall convention.
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:OQ**************@TK2MSFTNGP09.phx.gbl... > I also have a problem with "ref" paramaters, it says they need to be > assigned to before used > > Yet i have them used as "ref" in dll extern calls and checked for
non NULL > after yet it complains for non assignment so i use a local copy. > > Isnt it smart enough to detect that its being assinged in an extern dll call > as declared in DllImport? > > > > > "Nicholas Paldino [.NET/C# MVP]"
<ni**************@exisconsulting.com> wrote > in message news:#p**************@TK2MSFTNGP11.phx.gbl... > > Mr. Tickle, > > > > What is the declaration of the original function? If it takes
a > > pointer, then you should be using "ref" for the parameters, and
not out. > > Also, does the function take a 64-bit integer? Long in C is a 32-bit > > integer, where in .NET it is a 64-bit integer. > > > > The STDCALL mechanism should work if you are using it. > > > > Hope this helps. > > > > > > -- > > - Nicholas Paldino [.NET/C# MVP] > > - ni**************@exisconsulting.com > > > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > > news:Oo**************@TK2MSFTNGP09.phx.gbl... > > > I am calling an unmanaged DLL like follows in a Class wrapper. > > > > > > namespace blah > > > { > > > [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", > > > CallingConvention=CallingConvention.ThisCall] > > > public static extern void blahFn(out long blah, out long
blah2); > > > > > > class sealed ClassBlah > > > { > > > private ClassBlah() > > > { > > > } > > > > > > } > > > } > > > > > > Why have I to call this with the CallingConvention of ThisCall,
its > just > > > normal "C" functions in a DLL. Why wont StdCall work? > > > > > > What happens with other calling conventions is that the out parameters > are > > > NOT set, yet with ThisCall, they are set ok, or appear to be. I find it > > odd. > > > > > > > > > > > > Thanks > > > > > > > > > > > >
But I still dont understand why Thiscall works and the others dont.
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:uv**************@TK2MSFTNGP10.phx.gbl... Mr.Tickle,
In this case, you definitely want to use the int type, and pass it by reference. Your declaration should look like this:
[DllImport("somedll.dll")] public static extern int someFn(ref int someIDhere, ref int someIDhere2,
ref int someIDhere3);
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl... typedef SOME_ID long
SOME_ID someFn(SOME_ID* someIDhere, SOME_ID* someIDhere2, SOME_ID* someIDhere3);
something like that.
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote in message news:OB**************@TK2MSFTNGP11.phx.gbl... If you could post the original function declaration, it would help tremendously.
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:e6**************@TK2MSFTNGP09.phx.gbl... > i mean "out" oops. > > ref in the same dll wrapper still gets the output but only with thiscall > convention. > > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > news:OQ**************@TK2MSFTNGP09.phx.gbl... > > I also have a problem with "ref" paramaters, it says they need to
be > > assigned to before used > > > > Yet i have them used as "ref" in dll extern calls and checked for non NULL > > after yet it complains for non assignment so i use a local copy. > > > > Isnt it smart enough to detect that its being assinged in an exter
n dll > call > > as declared in DllImport? > > > > > > > > > > "Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> > wrote > > in message news:#p**************@TK2MSFTNGP11.phx.gbl... > > > Mr. Tickle, > > > > > > What is the declaration of the original function? If it
takes a > > > pointer, then you should be using "ref" for the parameters, and not out. > > > Also, does the function take a 64-bit integer? Long in C is a 32-bit > > > integer, where in .NET it is a 64-bit integer. > > > > > > The STDCALL mechanism should work if you are using it. > > > > > > Hope this helps. > > > > > > > > > -- > > > - Nicholas Paldino [.NET/C# MVP] > > > - ni**************@exisconsulting.com > > > > > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > > > news:Oo**************@TK2MSFTNGP09.phx.gbl... > > > > I am calling an unmanaged DLL like follows in a Class wrapper. > > > > > > > > namespace blah > > > > { > > > > [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", > > > > CallingConvention=CallingConvention.ThisCall] > > > > public static extern void blahFn(out long blah, out long blah2); > > > > > > > > class sealed ClassBlah > > > > { > > > > private ClassBlah() > > > > { > > > > } > > > > > > > > } > > > > } > > > > > > > > Why have I to call this with the CallingConvention of
ThisCall, its > > just > > > > normal "C" functions in a DLL. Why wont StdCall work? > > > > > > > > What happens with other calling conventions is that the out parameters > > are > > > > NOT set, yet with ThisCall, they are set ok, or appear to be.
I find > it > > > odd. > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > >
Because in you definition you only pass two arguments, while you need tree (an int, and to poiters).
It works while using the thiscall calling convention, because the interop layer passes as first argument an int for the this pointer
(three int's are reserved on the stack).
Willy.
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl... But I still dont understand why Thiscall works and the others dont.
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote in message news:uv**************@TK2MSFTNGP10.phx.gbl... Mr.Tickle,
In this case, you definitely want to use the int type, and pass it by reference. Your declaration should look like this:
[DllImport("somedll.dll")] public static extern int someFn(ref int someIDhere, ref int someIDhere2, ref int someIDhere3);
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl... typedef SOME_ID long
SOME_ID someFn(SOME_ID* someIDhere, SOME_ID* someIDhere2, SOME_ID* someIDhere3);
something like that.
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote in message news:OB**************@TK2MSFTNGP11.phx.gbl... > If you could post the original function declaration, it would help > tremendously. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - ni**************@exisconsulting.com > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > news:e6**************@TK2MSFTNGP09.phx.gbl... > > i mean "out" oops. > > > > ref in the same dll wrapper still gets the output but only with thiscall > > convention. > > > > > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > > news:OQ**************@TK2MSFTNGP09.phx.gbl... > > > I also have a problem with "ref" paramaters, it says they need to be > > > assigned to before used > > > > > > Yet i have them used as "ref" in dll extern calls and checked for non > NULL > > > after yet it complains for non assignment so i use a local copy. > > > > > > Isnt it smart enough to detect that its being assinged in an exter n dll > > call > > > as declared in DllImport? > > > > > > > > > > > > > > > "Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> > > wrote > > > in message news:#p**************@TK2MSFTNGP11.phx.gbl... > > > > Mr. Tickle, > > > > > > > > What is the declaration of the original function? If it takes a > > > > pointer, then you should be using "ref" for the parameters, and not > out. > > > > Also, does the function take a 64-bit integer? Long in C is a 32-bit > > > > integer, where in .NET it is a 64-bit integer. > > > > > > > > The STDCALL mechanism should work if you are using it. > > > > > > > > Hope this helps. > > > > > > > > > > > > -- > > > > - Nicholas Paldino [.NET/C# MVP] > > > > - ni**************@exisconsulting.com > > > > > > > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > > > > news:Oo**************@TK2MSFTNGP09.phx.gbl... > > > > > I am calling an unmanaged DLL like follows in a Class wrapper. > > > > > > > > > > namespace blah > > > > > { > > > > > [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", > > > > > CallingConvention=CallingConvention.ThisCall] > > > > > public static extern void blahFn(out long blah, out long blah2); > > > > > > > > > > class sealed ClassBlah > > > > > { > > > > > private ClassBlah() > > > > > { > > > > > } > > > > > > > > > > } > > > > > } > > > > > > > > > > Why have I to call this with the CallingConvention of ThisCall, its > > > just > > > > > normal "C" functions in a DLL. Why wont StdCall work? > > > > > > > > > > What happens with other calling conventions is that the out > parameters > > > are > > > > > NOT set, yet with ThisCall, they are set ok, or appear to be. I find > > it > > > > odd. > > > > > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
Well its suppost to match up, its just something i typed in a hurry but it
is the same number of arguments in the definition and call. on teh real
code.
the dll definition would be
typedef SOMEVAL long
typedef SOME_ID long
SOME_ID someFn(SOMEVAL someVal, SOME_ID* someIDhere, SOME_ID* someIDhere2,
SOME_ID* someIDhere3);
so im calling with for example out of my memory
DllImport("somedll.dll", EntryPoint="blahFn",
CallingConvention=CallingConvention.ThisCall)]
public static extern int someFn(long someVal, ref someIDhere, ref long
someIDhere2, ref long someIDhere3);
// i know this should be int instead of long but curious why the long works
with thiscall and not the others or just not work at all.
long someVal;
long ID someID,
anotherID,
yetAnohterID,
andAnotherID;
someID = blahFn(someVal, ref anotherID, ref yetAnotherID, ref andAnotherID);
Only thiscall works, others dont, so if i understand it right I change the
definition from long to int for 32bit instead of the 64bit on the .net side,
and then i can use stdcall as normal.
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:OE**************@tk2msftngp13.phx.gbl... Because in you definition you only pass two arguments, while you need tree
(an int, and to poiters). It works while using the thiscall calling convention, because the interop
layer passes as first argument an int for the this pointer (three int's are reserved on the stack).
Willy.
"Mr.Tickle" <Mr******@mrmen.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... But I still dont understand why Thiscall works and the others dont.
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com>
wrote in message news:uv**************@TK2MSFTNGP10.phx.gbl... Mr.Tickle,
In this case, you definitely want to use the int type, and pass it
by reference. Your declaration should look like this:
[DllImport("somedll.dll")] public static extern int someFn(ref int someIDhere, ref int
someIDhere2, ref int someIDhere3);
-- - Nicholas Paldino [.NET/C# MVP] - ni**************@exisconsulting.com
"Mr.Tickle" <Mr******@mrmen.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl... > typedef SOME_ID long > > SOME_ID someFn(SOME_ID* someIDhere, SOME_ID* someIDhere2, SOME_ID* > someIDhere3); > > something like that. > > > "Nicholas Paldino [.NET/C# MVP]"
<ni**************@exisconsulting.com> wrote > in message news:OB**************@TK2MSFTNGP11.phx.gbl... > > If you could post the original function declaration, it would
help > > tremendously. > > > > > > -- > > - Nicholas Paldino [.NET/C# MVP] > > - ni**************@exisconsulting.com > > > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > > news:e6**************@TK2MSFTNGP09.phx.gbl... > > > i mean "out" oops. > > > > > > ref in the same dll wrapper still gets the output but only with thiscall > > > convention. > > > > > > > > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > > > news:OQ**************@TK2MSFTNGP09.phx.gbl... > > > > I also have a problem with "ref" paramaters, it says they need
to be > > > > assigned to before used > > > > > > > > Yet i have them used as "ref" in dll extern calls and checked
for non > > NULL > > > > after yet it complains for non assignment so i use a local
copy. > > > > > > > > Isnt it smart enough to detect that its being assinged in an
exter n > dll > > > call > > > > as declared in DllImport? > > > > > > > > > > > > > > > > > > > > "Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> > > > wrote > > > > in message news:#p**************@TK2MSFTNGP11.phx.gbl... > > > > > Mr. Tickle, > > > > > > > > > > What is the declaration of the original function? If it takes a > > > > > pointer, then you should be using "ref" for the parameters,
and not > > out. > > > > > Also, does the function take a 64-bit integer? Long in C is
a > 32-bit > > > > > integer, where in .NET it is a 64-bit integer. > > > > > > > > > > The STDCALL mechanism should work if you are using it. > > > > > > > > > > Hope this helps. > > > > > > > > > > > > > > > -- > > > > > - Nicholas Paldino [.NET/C# MVP] > > > > > - ni**************@exisconsulting.com > > > > > > > > > > "Mr.Tickle" <Mr******@mrmen.com> wrote in message > > > > > news:Oo**************@TK2MSFTNGP09.phx.gbl... > > > > > > I am calling an unmanaged DLL like follows in a Class
wrapper. > > > > > > > > > > > > namespace blah > > > > > > { > > > > > > [DllImport("DLLName.DLL", EntryPoint="BlahEntryPoint", > > > > > > CallingConvention=CallingConvention.ThisCall] > > > > > > public static extern void blahFn(out long blah, out long blah2); > > > > > > > > > > > > class sealed ClassBlah > > > > > > { > > > > > > private ClassBlah() > > > > > > { > > > > > > } > > > > > > > > > > > > } > > > > > > } > > > > > > > > > > > > Why have I to call this with the CallingConvention of ThisCall, > its > > > > just > > > > > > normal "C" functions in a DLL. Why wont StdCall work? > > > > > > > > > > > > What happens with other calling conventions is that the
out > > parameters > > > > are > > > > > > NOT set, yet with ThisCall, they are set ok, or appear to
be. I > find > > > it > > > > > odd. > > > > > > > > > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mr.Tickle |
last post by:
I am calling an unmanaged DLL like follows in a Class wrapper.
namespace blah
{
public static extern void blahFn(out long blah, out long blah2);
class sealed ClassBlah
{
private...
|
by: Mr.Tickle |
last post by:
I am calling an unmanaged DLL like follows in a Class wrapper.
namespace blah
{
public static extern void blahFn(out long blah, out long blah2);
class sealed ClassBlah
{
private...
|
by: Mr.Tickle |
last post by:
I am calling an unmanaged DLL like follows in a Class wrapper.
namespace blah
{
public static extern void blahFn(out long blah, out long blah2);
class sealed ClassBlah
{
private...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |