Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#1

Standard DLL in VB geschrieben

  Alt 21. Sep 2008, 21:20
Für die ganz schlauen hier die meinen das es nicht geht.. @Elvis
Lebst vielleicht doch hinterm Mond ? hihiiihi nur Spass

"DLL"
Delphi-Quellcode:
Function DLLMain(ByVal A As Long, ByVal B As Long, ByVal c As Long) As Long
    DLLMain = 1
End Function

Sub Main()
    //This is a dummy, so the IDE doesn't complain
    //there is no Sub Main.
End Sub

//add more functions here, ie.
Function addition(ByVal A As Double, ByVal B As Double) As Double
  addition = A + B
End Function

Function subtraction(ByVal A As Double, ByVal B As Double) As Double
  subtraction = A - B
End Function

Function showmsg() As String
Dim sInput As Long
Dim intMin As Integer
Dim intSec As Integer
Dim TimeString As String

    sInput = InputBox("Bitte Zeit in MilliSekunden eingeben", "Result Zeit in Sekunden")
    If sInput > 0 Then
        intMin = sInput \ 60
        intSec = Int(sInput - intMin * 60)
        TimeString = Format$(intMin, "00") & ":" & Format$(intSec, "00")
    End If

    showmsg = TimeString
  
End Function
"Anwendung"
Delphi-Quellcode:
Private Declare Function subtraction Lib "TestDLL.DLL" (ByVal A As Double, ByVal B As Double) As Double
Private Declare Function addition Lib "TestDLL.DLL" (ByVal A As Double, ByVal B As Double) As Double
Private Declare Function showmsg Lib "TestDLL.DLL" () As Long

// Windows API Declaration
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" ( _
    ByVal lpString As Long _
) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
    ByRef Destination As Any, _
    ByRef Source As Any, _
    ByVal Length As Long _
)

Private Sub btnTime_Click()
    lblTime.Caption = VBStrFromAnsiPtr(showmsg())
End Sub

Private Sub cmdExit_Click()
End
End Sub

Private Sub Form_Load()
lblResult(0) = "9.87 + 2.99 = " & CStr(addition(9.87, 2.99))
lblResult(1) = "10 - 8.43 = " & CStr(subtraction(10, 8.43))
lblResult(2) = "9999 + 1543 = " & CStr(addition(9999, 1543))
End Sub

Private Function VBStrFromAnsiPtr(ByVal lpStr As Long) As String
Dim bStr() As Byte
Dim cChars As Long
    On Error Resume Next
    // Get the number of characters in the buffer
    cChars = lstrlen(lpStr)
    // Resize the byte array
    ReDim bStr(0 To cChars - 1) As Byte
    // Grab the ANSI buffer
    Call CopyMemory(bStr(0), ByVal lpStr, cChars)
    // Now convert to a VB Unicode string
    VBStrFromAnsiPtr = StrConv(bStr, vbUnicode)
End Function
Test im Anhang

Edit:
hab noch eine Function angehängt
Miniaturansicht angehängter Grafiken
dependency_156.jpg  
Angehängte Dateien
Dateityp: rar compiled_112.rar (6,6 KB, 12x aufgerufen)
  Mit Zitat antworten Zitat