Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    DLLImport-puntatore DWORD

    Salve a tutti sono nuovo e sto letteralmente impazzendo nel cercare di gestire una DLL standard call in un progetto vb2008 devo utilizzare questa funzione per prendere dei valori di temperatura da un apparecchio collegato al PC tramite USB:

    dal file .h della DLL risulta:

    DllExport BOOL _stdcall GetPCBTemperature(DWORD Card, DWORD *Temp);

    dove Temp è Temp[3] DWORD

    che ho tradotto in un modulo vb:

    Imports System.Runtime.InteropServices

    <DllImport("BoxDLL.dll", EntryPoint:="GetPCBTemperature", ExactSpelling:=False, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.StdCall)> _
    Public Function GetPCBTemperature(ByVal Card As UInteger, ByRef Temp() As UInteger) As Boolean
    End Function

    e che richiamo come:

    Dim T() As UInteger = {0, 0, 0}
    Debug.Print(GetPCBTemperature(1, T))

    ma mi restituisce sempre T=Nothing

    Ho provato anche con:

    Imports System.Runtime.InteropServices

    <DllImport("BoxDLL.dll", EntryPoint:="GetPCBTemperature", ExactSpelling:=False, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.StdCall)> _
    Public Function GetPCBTemperature(ByVal Card As UInteger, ByRef Temp As IntPtr) As Boolean
    End Function

    Dim T() As UInteger = {0, 0, 0}
    Debug.Print(GetPCBTemperature(1, T(0)))

    e il risultato è = {0, 0, 0} (con il caldo che fa oggi ! :berto: )

    Non ero molto preparato sull'argomento, dopo essermi documentato un po' adesso posso dire di aver raggiunto un bun stato confusionale !!!

    Qualcuno ha giò affrontato questi problemi?

  2. #2
    Prova con
    codice:
    <DllImport("BoxDLL.dll", EntryPoint:="GetPCBTemperature", ExactSpelling:=True, CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.StdCall)> _
    Public Function GetPCBTemperature(ByVal Card As UInteger, <MarshalAs(UnmanagedType.LPArray)> Temp() As UInteger) As Boolean
    End Function
    Amaro C++, il gusto pieno dell'undefined behavior.

  3. #3
    nulla, mi restituisce sempre 0,0,0 :master: cmq grazie per l'aiuto!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.