Hi,
Can anyone show me how to create a DLL that can accept a string as a parameter. I am trying to create the DLL in assembly and have VB call the DLL.
Thanks,
bg
Can anyone show me how to create a DLL that can accept a string as a parameter. I am trying to create the DLL in assembly and have VB call the DLL.
Thanks,
bg
Here is some MASM code to start you:
in your dll asm file:
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
.code
DllEntry proc hInstDLL:HINSTANCE, reason:DWORD, reserved1:DWORD
mov eax,TRUE
ret
DllEntry Endp
ShowStringFromVB proc StringIn:DWORD
invoke MessageBox, NULL, StringIn, NULL, MB_OK
ret
ShowStringFromVB endp
End DllEntry
in your dll def file:
LIBRARY VBDll
EXPORTS ShowStringFromVB
in VB:
Private Declare Sub ShowStringFromVB Lib "E:\Projects\VBDll\vbdll" ( _
ByVal StringIn As String)
Private Sub Command1_Click()
ShowStringFromVB Text1.Text
End Sub
in your dll asm file:
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
.code
DllEntry proc hInstDLL:HINSTANCE, reason:DWORD, reserved1:DWORD
mov eax,TRUE
ret
DllEntry Endp
ShowStringFromVB proc StringIn:DWORD
invoke MessageBox, NULL, StringIn, NULL, MB_OK
ret
ShowStringFromVB endp
End DllEntry
in your dll def file:
LIBRARY VBDll
EXPORTS ShowStringFromVB
in VB:
Private Declare Sub ShowStringFromVB Lib "E:\Projects\VBDll\vbdll" ( _
ByVal StringIn As String)
Private Sub Command1_Click()
ShowStringFromVB Text1.Text
End Sub
Hi Gunner,
Thanks for shedding some light on something that was giving me a hard time. I was NOT using ByVal in my VB declaration. Would you be willing to show me how to break the StringIn:DWORD parameter down character by character? Thanks once again for your time.
bg
Thanks for shedding some light on something that was giving me a hard time. I was NOT using ByVal in my VB declaration. Would you be willing to show me how to break the StringIn:DWORD parameter down character by character? Thanks once again for your time.
bg
Your best friend while learning Assembly is the search feature of this board (Try searching for String parsing) and the tutorials at:
http://win32assembly.online.fr/
http://win32assembly.online.fr/
bgong68,
if you had bothered to do a search of the board, you would have seen that i have already posted several reasonably technical descriptions on what happens when you pass a string from VB to asm, how to do it, and how to get a changed string back.
Check this thread and this thread.
if you had bothered to do a search of the board, you would have seen that i have already posted several reasonably technical descriptions on what happens when you pass a string from VB to asm, how to do it, and how to get a changed string back.
Check this thread and this thread.