can vb.net support WINAPI(_stadcall)?

  • Thread starter Thread starter jg
  • Start date Start date
What have you tried ? See the Declare statement or the DllImport
attribute...

Patrice
 
thank you for your prompt reply.


I should have mentioned that I want the .net dll to support WINAPI(stdcall)
by non managed client.

I did not think of dllimport. Nonetheless I will Google on ddlimport

I was running into a brick wall when it comes to exposing methods and
function with string and /or integer array to the unmanaged client when I
was using the COM interface. I tried a myriad of marshalas, pin, intptr,
varptr. Either I goofed big time or, I just did not get it.

I just found out the unmanaged client supports WINAPI(_stadcall) as well as
COM, OCX.

So I am looking at the possibility of using WINAPI(_stadcall) on my .net
class dll.
 
AFAIK both VB.NET and C# are unabled to "export" DLL functions as done by
the Windows API (they are able to use existing functions).
If you want to expose functions to COM I would still try to solve the
original problem. AFAIK .NET should likely default to exposing this as safe
arrays. You could post your original problme with the effects you have to
the interop group...

I thought first you wanted to consume Windows API functions (my
understanding is now that you want actually to expose functions to the
unmanaged world).
 
COM is the way to go if you want to expose a .Net assembly`s methods to the
unmanaged world


regards

Michel
 
There seem to be a lot more documentation and sample of .net consuming
WINAPI(_stadcall) than the other way. I look more so for arrays

That is why I am tempted to look into WINAPI(_stadcall) when I do have some
control over the unmanaged application. I could get the developer to
partition the unmanaged application into two DLLs: data processing and
analytical presentation, let the .net not handle menu, the internet explorer
navigation, parsing.
 
just for those who have to deal with legacy application that supports COM,
OCX, and WINAPI(_stadcall),
I worked out the COM interface fro function out array parametns.


For example
' Caller proto:
' Int32 lSz, lsz2
' String lstrOut[]
' Int32 lPos[]
' lSz = objClass.Parse(sIn, ref lsz2, ref lstrOut, ref lPos)
' the result lsz2 and lSz are same of course due to adj made here

Public Function Parse(ByVal sIn As String, <Out()> ByRef iCnt As Integer, _

<Out()> <MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.LPStr,
SizeParamIndex:=1)> ByRef sOut As String(), _

<Out()> <MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.LPStr,
SizeParamIndex:=1)> ByRef lPos As Integer()) As Integer

sOut = Split(sIn, vbTab)

Dim sdebugMsg As String = "0, >>", s As String

Dim i As Integer = 0

iCnt = 0

iCnt = sOut.GetUpperBound(0)

Dim pos(iCnt) As Integer

If iCnt > 0 Then

pos(0) = 1

i = 1

For Each s In sOut

sdebugMsg &= s

If i < iCnt Then

pos(i) = s.Length + 1

sdebugMsg &= vbCrLf & pos(i) & vbTab

End If

Next

lPos = pos

iCnt += 1

Else

End If

' MsgBox("sOut.GetUpperBound()=" & sOut.GetUpperBound(0) & vbCrLf & "values
are" & vbCrLf & sdebugMsg, MsgBoxStyle.OKOnly, "IeStringClass.Parse")

'MsgBox(sOut)

Return iCnt

End Function
 
I just found the form handle event by itself in the class will let me
initialize but I still get object problem that I will post on another thread
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top