Ik probeer met VB 2010 de parallelle poort aan te sturen, alles gaat goed tot nu toe, maar bij IO.dll invoegen krijg ik foutmeldingen.
Module Io
Option Strict Off
Option Explicit On
Module io
Public Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)
Public Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Integer)
Public Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Long)
Public Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As Byte
Public Declare Function PortWordIn Lib "IO.DLL" (ByVal Port As Integer) As Integer
Public Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Integer) As Long
Public Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte) As Boolean
Public Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function IsDriverInstalled Lib "IO.DLL" () As Boolean
End Module
End Module
Error 1 'Option' statements must precede any declarations or 'Imports' statements. (2 keer)
Error 3 'Module' statements can occur only at file or namespace level.
Iemand een idee wat ik verkeerd doe?
Maak eens een nieuwe module er plak daar het volgende in:
Public Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)
Public Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Integer)
Public Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Long)
Public Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As Byte
Public Declare Function PortWordIn Lib "IO.DLL" (ByVal Port As Integer) As Integer
Public Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Integer) As Long
Public Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte) As Boolean
Public Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function IsDriverInstalled Lib "IO.DLL" () As Boolean
Leime
0 errors! Bedankt 
Edit: Te vroeg gejuicht: "Unable to load DLL 'IO.DLL': Kan opgegeven module niet vinden. (Exception from HRESULT: 0x8007007E)"
De dll staat nochtans wel in de system32 map
[Bericht gewijzigd door T-baev op (82%)]
Op 20 mei 2010 22:03:03 schreef T-baev:
0 errors! BedanktEdit: Te vroeg gejuicht: "Unable to load DLL 'IO.DLL': Kan opgegeven module niet vinden. (Exception from HRESULT: 0x8007007E)"
De dll staat nochtans wel in de system32 map
Moet die DLL niet in bij je EXE staan?
ja, de dll moet in dezelfde map als waar je projectbestanden staan
[Bericht gewijzigd door leime op (27%)]
en als je "Option Strict Off" en "Option Explicit On" wil gebruiken moet je dat boven "module IO"
Option Strict Off
Option Explicit On
Module io
Public Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)
Public Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Integer)
Public Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Long)
Public Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As Byte
Public Declare Function PortWordIn Lib "IO.DLL" (ByVal Port As Integer) As Integer
Public Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Integer) As Long
Public Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Public Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte) As Boolean
Public Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Public Declare Function IsDriverInstalled Lib "IO.DLL" () As Boolean
End Module
Je kan ook eens proberen om de dll aan je project toe te voegen, dit doe je door in je "solution exporer" rechtsklik op je project naam en dan add, exisiting item.
Op 20 mei 2010 22:27:11 schreef T-baev:
[...]Met de map met prokectbestanden bedoel je toch de map waarim het programma is opgeslaan he?
De dll zou moeten staan bij E:\Documents\Visual Studio 2010\Projects\PROJECTNAAM\PROJECTNAAM\bin\Debug\HIER DLL
de dll toegevoegd via existing item, hetzelfde verhaal.
In de map visual studio 2010 zit geen map met de naam projects.
EDIT: Ik heb de map projects gevonden en deze is leeg.
[Bericht gewijzigd door T-baev op (19%)]
Oke, ik heb nu een andere IO.dll gesownload en in bin/debug gezet en nu werkt het. Het was gewoon een slechte dll.
Progger
GMT+1
ohw, grappig
normaal zet je de DLL in windows/System32. als die daar niet in staat zal hij zoeken in de map waar het exe bestand ook in staat (of andersom). meestal is dit je projectmap/bin
Progger
GMT+1
dan is deze wellicht niet geregistreerd. iets met start->uitvoeren->RegSvr32 C:\Windows\System32\iodll.DLL
misschien heb je hier wat aan, dit is mijn eigen proggamatje
het is gescheven in een oudere VB
Public Class Form1
Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Short) As Short
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Short, ByVal Value As Short)
Dim bit1 As Short = 0
Dim bit2 As Short = 0
Dim bit3 As Short = 0
Dim bit4 As Short = 0
Dim bit5 As Short = 0
Dim bit6 As Short = 0
Dim bit7 As Short = 0
Dim bit8 As Short = 0
Dim bitout As Short = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If bit1 = 1 Then bit1 = 0 Else bit1 = 1
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If bit2 = 2 Then bit2 = 0 Else bit2 = 2
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If bit3 = 4 Then bit3 = 0 Else bit3 = 4
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If bit4 = 8 Then bit4 = 0 Else bit4 = 8
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If bit5 = 16 Then bit5 = 0 Else bit5 = 16
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If bit6 = 32 Then bit6 = 0 Else bit6 = 32
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If bit7 = 64 Then bit7 = 0 Else bit7 = 64
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If bit8 = 128 Then bit8 = 0 Else bit8 = 128
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
bitout = bit1 + bit2 + bit3 + bit4 + bit5 + bit6 + bit7 + bit8
TextBox1.Text = Inp(&H378)
Out(&H378, bitout)
End Sub
End Class