我的VB版本是6.0第一個問題是請問我的STRUCTURE SIZE 到底是多少?因為我的程式會呼叫到我自己用C寫的DLL FUNCTION,而傳遞的參數是這個STRUCTURE ARRAY 的指標值,我算了一下應該是139BYTES,為什麼我將這個參數傳到DLL後發現是148BYTES,請問到底我是哪裡出錯了
Public Type Storage
Adap_Id As Byte
Flags As Byte
SCSI_Id As Byte
SCSI_Lun As Byte
drive_ID As String * 8
PID As String * 16
VID As String * 16
sectorSize As Long
maxSectors As Byte
maxBlocks As Integer
maxZones As Byte
maxChips As Byte
maxLogBlocks As Integer
maxLogZone As Byte
maxsectorSize As Long
TotalPhyBlk As Integer
SerialNumber As String * 16
curLUN0SecNum As Long
curUnProtectSec As Long
secPblk As Integer
TotalSec As Long
DiskInfo As String * 24
password As String * 4
newLUN0SecNum As Long
newUnProtectSec As Long
mirror_Drive As String * 8
bootType As Byte
action As Integer
End Type
第二個問題,請問如果我這樣寫
Option Explicit
Dim My_Storage(0 To 25) As Storage
請問VB是不是就會配置一塊連續位址的記憶體給我,但是在DLL裡卻看到不是,而是我去傳那個陣列的指標他才會去配置記憶體,例如我這樣寫
SCANDEVICE(My_Storage(0))
SCANDEVICE(My_Storage(25))
在我的DLL裡去看就會看到My_Storage(25)會接在My_Storage(0)後,但是位址卻是My_Storage(25)位址是在My_Storage(0)之上,也就是說假設My_Storage(25)的記憶體位置是0x00000000那My
_Storage(0)位址是在0x00000094,My_Storage(1)不見了,同理如果我一連呼叫多次同樣的FUNCTION,就會配置你傳的參數大小的寄液體給你,這也是我第三個問題,我的DLL FUNCTION宣告如下
Public Declare Function SCANDEVICE Lib "fmt_dll" _
(ByRef My_Storage As Storage) As Byte
Public Type Storage
Adap_Id As Byte
Flags As Byte
SCSI_Id As Byte
SCSI_Lun As Byte
drive_ID As String * 8
PID As String * 16
VID As String * 16
sectorSize As Long
maxSectors As Byte
maxBlocks As Integer
maxZones As Byte
maxChips As Byte
maxLogBlocks As Integer
maxLogZone As Byte
maxsectorSize As Long
TotalPhyBlk As Integer
SerialNumber As String * 16
curLUN0SecNum As Long
curUnProtectSec As Long
secPblk As Integer
TotalSec As Long
DiskInfo As String * 24
password As String * 4
newLUN0SecNum As Long
newUnProtectSec As Long
mirror_Drive As String * 8
bootType As Byte
action As Integer
End Type
第二個問題,請問如果我這樣寫
Option Explicit
Dim My_Storage(0 To 25) As Storage
請問VB是不是就會配置一塊連續位址的記憶體給我,但是在DLL裡卻看到不是,而是我去傳那個陣列的指標他才會去配置記憶體,例如我這樣寫
SCANDEVICE(My_Storage(0))
SCANDEVICE(My_Storage(25))
在我的DLL裡去看就會看到My_Storage(25)會接在My_Storage(0)後,但是位址卻是My_Storage(25)位址是在My_Storage(0)之上,也就是說假設My_Storage(25)的記憶體位置是0x00000000那My
_Storage(0)位址是在0x00000094,My_Storage(1)不見了,同理如果我一連呼叫多次同樣的FUNCTION,就會配置你傳的參數大小的寄液體給你,這也是我第三個問題,我的DLL FUNCTION宣告如下
Public Declare Function SCANDEVICE Lib "fmt_dll" _
(ByRef My_Storage As Storage) As Byte
全站熱搜
留言列表