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
Posted on 2002-11-02 21:06:54 by bgong68
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
Posted on 2002-11-02 21:44:47 by Gunner
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
Posted on 2002-11-02 22:27:01 by bgong68
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/
Posted on 2002-11-02 22:52:47 by Gunner
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.
Posted on 2002-11-03 05:15:08 by sluggy