- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Needing some help with excel/vba dll calls. I used the following declare sub and was not sure if the additional records being passed with the BSTR for a string need to be put into the @bytes number? Can someone tell me exactly what bytes number should be specified for this example?
Declare Sub dll_rout Lib "C:dll_rout.dll" _
Alias "_DLL_ROUT@12" (int_arg As Long, ByVal str_in As String, ByVal str_in_len As Long, ByVal str_out As String, ByVal Str_out_len As Long)
Example link below.
http://www.compaq.com/fortran/examples/vb-example1.html
Thanks
Ken
Needing some help with excel/vba dll calls. I used the following declare sub and was not sure if the additional records being passed with the BSTR for a string need to be put into the @bytes number? Can someone tell me exactly what bytes number should be specified for this example?
Declare Sub dll_rout Lib "C:dll_rout.dll" _
Alias "_DLL_ROUT@12" (int_arg As Long, ByVal str_in As String, ByVal str_in_len As Long, ByVal str_out As String, ByVal Str_out_len As Long)
Example link below.
http://www.compaq.com/fortran/examples/vb-example1.html
Thanks
Ken
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tried it. 20.
I use dumpbin /exports to check it.
I use dumpbin /exports to check it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are 5 arguments passed. Each in the size of 4 bytes. Hence , 5x4 = 20.
Adding extra argment inside the dll_rout.dll will yield 24 (6 arguments x 4 bytes).
Adding extra argment inside the dll_rout.dll will yield 24 (6 arguments x 4 bytes).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Edmund,
I noticed that if I take out the allias attribute in the fortran dll it does not indicate how many bytes are needed.
Have you gotten this example to work?
Ken
I noticed that if I take out the allias attribute in the fortran dll it does not indicate how many bytes are needed.
Have you gotten this example to work?
Ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes.It worked for me. I even use a cell value as input (see code below). If you want to try it, make sure the cell's property is set to numeric. (note I save the file name as sub1.dll)
Declare Sub DLL_ROUT Lib _
"e:sub1.dll" _
(int_arg As Long, _
ByVal STR_IN As String, _
ByVal STR_IN_LEN As Long, _
ByVal STR_OUT As String, _
ByVal STR_OUT_LEN As Long)
Public Sub Command1_Click()
Dim int_arg As Long
Static STR_IN As String * 10, STR_OUT As String * 20
int_arg = Cells(1, 1).Value
STR_IN = "Testing..."
Rem Pass lengths of string arguments
Call DLL_ROUT(int_arg, STR_IN, Len(STR_IN), STR_OUT, Len(STR_OUT))
MsgBox (STR_OUT)
End Sub
I tried your case by removing the alias attribute. It is interesting to see that from dumpbin /exports, there were two entry points for the subroutines(both fortran/stdcall types). This probably means you don't have to worry about using _alias_at all in your fortran dll. (well, I could be wrong but it works in this example)
Declare Sub DLL_ROUT Lib _
"e:sub1.dll" _
(int_arg As Long, _
ByVal STR_IN As String, _
ByVal STR_IN_LEN As Long, _
ByVal STR_OUT As String, _
ByVal STR_OUT_LEN As Long)
Public Sub Command1_Click()
Dim int_arg As Long
Static STR_IN As String * 10, STR_OUT As String * 20
int_arg = Cells(1, 1).Value
STR_IN = "Testing..."
Rem Pass lengths of string arguments
Call DLL_ROUT(int_arg, STR_IN, Len(STR_IN), STR_OUT, Len(STR_OUT))
MsgBox (STR_OUT)
End Sub
I tried your case by removing the alias attribute. It is interesting to see that from dumpbin /exports, there were two entry points for the subroutines(both fortran/stdcall types). This probably means you don't have to worry about using _alias_at all in your fortran dll. (well, I could be wrong but it works in this example)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page