Click here to Skip to main content
15,889,335 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How do I check programmatically if installed version of ACE OleDb is 64 or 32 bit version? Pin
Dave Kreskowiak10-Feb-12 3:33
mveDave Kreskowiak10-Feb-12 3:33 
AnswerRe: How do I check programmatically if installed version of ACE OleDb is 64 or 32 bit version? Pin
yanghua9414-Feb-12 5:42
yanghua9414-Feb-12 5:42 
QuestionvsFlexgrid 8 ActiveX Pin
Jim Giles9-Feb-12 10:39
Jim Giles9-Feb-12 10:39 
QuestionWhat should i install ? Pin
alejx9-Feb-12 3:55
alejx9-Feb-12 3:55 
AnswerRe: What should i install ? Pin
Simon_Whale9-Feb-12 4:22
Simon_Whale9-Feb-12 4:22 
GeneralRe: What should i install ? Pin
alejx9-Feb-12 7:23
alejx9-Feb-12 7:23 
GeneralRe: What should i install ? Pin
Framework .l.9-Feb-12 14:18
Framework .l.9-Feb-12 14:18 
QuestionProblems with marshaling Pin
Florian Krätschmer8-Feb-12 23:42
Florian Krätschmer8-Feb-12 23:42 
I want to integrate an "old DLL" in which a function is called, in which I must pass two structures ByRef. The functions and structures:

VB
<System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet:=System.Runtime.InteropServices.CharSet.Ansi, Pack:=1)> _
   Public Structure BitRec
       <MarshalAs(UnmanagedType.ByValArray, SizeConst:=20)> Public iBit() As Integer
       Public iState As Integer
       Public iTime As Integer
   End Structure


VB
<System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet:=System.Runtime.InteropServices.CharSet.[Ansi], Pack:=1)> _
    Public Structure MixCalcRec
        Public dLeistung As Double
        Public dTemp1 As Double
        Public dEinlauf As Double
        Public dAuslauf As Double
        Public dStempelWeg As Double
        Public dDrehzahl As Double
    End Structure


VB
<System.Runtime.InteropServices.DllImportAttribute("DPCALC", EntryPoint:="_CalcMixData@28", CallingConvention:=System.Runtime.InteropServices.CallingConvention.StdCall)> _
   Public Shared Function CalcMixDataDLL(ByRef AnalogData As MixCalcRec, ByVal iArraySize As Integer, ByRef BitArray As BitRec, ByVal iBitSize As Integer, ByVal iMode As Integer, ByVal dbDistance As Double) As Integer
   End Function


VB
Public Function CalcMixData(ByRef AnalogData As MixCalcRec, ByVal iArraySize As Integer, ByRef BitArray As BitRec, ByVal iBitSize As Integer, ByVal iMode As Integer, ByVal dbDistance As Double) As Integer
        Dim ireturn As Integer = 0
        Dim iSizeOfOneStruct1 As Integer = Marshal.SizeOf(GetType(MixCalcRec))
        Dim iTotalSize1 As Integer = iSizeOfOneStruct1 * iArraySize
        Dim pUnmanagedAnalogDaten As IntPtr = Marshal.AllocCoTaskMem(iTotalSize1)
        Marshal.StructureToPtr(AnalogData, pUnmanagedAnalogDaten, False)
        Dim iSizeOfOneStruct2 As Integer = Marshal.SizeOf(GetType(BitRec))
        Dim iTotalSize2 As Integer = iSizeOfOneStruct2 * iBitSize
        Dim pUnmanagedBitDaten As IntPtr = Marshal.AllocCoTaskMem(iTotalSize2)
        Marshal.StructureToPtr(BitArray, pUnmanagedBitDaten, False)
        ireturn = CalcMixDataDLL(pUnmanagedAnalogDaten, iArraySize, pUnmanagedBitDaten, iBitSize, iMode, dbDistance)
        Marshal.FreeCoTaskMem(pUnmanagedAnalogDaten)
        Marshal.FreeCoTaskMem(pUnmanagedBitDaten)
        CalcMixData = ireturn
    End Function



After calling the Function in the DLL wrapper i get an error that I attempted to read or write in protected memory. Can someone help me with that? What am I doing wrong? I think the structures and the DLL declaration are OK. I guess something's wrong in the DLL wrapper.

Thanks for your help.
QuestionA code in VB.NET. Pin
hansoctantan8-Feb-12 22:40
professionalhansoctantan8-Feb-12 22:40 
AnswerRe: A code in VB.NET. Pin
JR2129-Feb-12 1:40
JR2129-Feb-12 1:40 
AnswerRe: A code in VB.NET. Pin
Simon_Whale9-Feb-12 1:59
Simon_Whale9-Feb-12 1:59 
AnswerRe: A code in VB.NET. Pin
Dave Kreskowiak9-Feb-12 2:10
mveDave Kreskowiak9-Feb-12 2:10 
GeneralRe: A code in VB.NET. Pin
hansoctantan9-Feb-12 3:28
professionalhansoctantan9-Feb-12 3:28 
AnswerRe: A code in VB.NET. Pin
Bernhard Hiller9-Feb-12 22:02
Bernhard Hiller9-Feb-12 22:02 
GeneralRe: A code in VB.NET. Pin
Simon_Whale9-Feb-12 22:53
Simon_Whale9-Feb-12 22:53 
QuestionDatagridview not showing my list(of object) Pin
Sonhospa8-Feb-12 8:22
Sonhospa8-Feb-12 8:22 
AnswerRe: Datagridview not showing my list(of object) Pin
Luc Pattyn8-Feb-12 9:30
sitebuilderLuc Pattyn8-Feb-12 9:30 
General(Resolved): Datagridview not showing my list(of object) Pin
Sonhospa10-Feb-12 0:36
Sonhospa10-Feb-12 0:36 
AnswerRe: (Resolved): Datagridview not showing my list(of object) Pin
Luc Pattyn10-Feb-12 1:01
sitebuilderLuc Pattyn10-Feb-12 1:01 
AnswerRe: Datagridview not showing my list(of object) Pin
Simon_Whale9-Feb-12 22:58
Simon_Whale9-Feb-12 22:58 
AnswerRe: Datagridview not showing my list(of object) Pin
Luc Pattyn9-Feb-12 23:38
sitebuilderLuc Pattyn9-Feb-12 23:38 
GeneralRe: Datagridview not showing my list(of object) Pin
Simon_Whale9-Feb-12 23:44
Simon_Whale9-Feb-12 23:44 
General(Resolved): Datagridview not showing my list(of object) Pin
Sonhospa10-Feb-12 0:40
Sonhospa10-Feb-12 0:40 
GeneralRe: (Resolved): Datagridview not showing my list(of object) Pin
Simon_Whale10-Feb-12 1:07
Simon_Whale10-Feb-12 1:07 
QuestionDiamond Looping Pin
Framework .l.7-Feb-12 14:51
Framework .l.7-Feb-12 14:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.