VBAのLongLongからdllの__int64へ値を渡すと数字が壊れます。
なぜでしょうか?
少しわかってきました。
一つ目と二つ目の引数を入れ替えたら、一つ目の引数はちゃんと渡るのに二つ目の引数が壊れるようです。
C++ dll 側の宣言
extern "C" __declspec(dllexport) long __stdcall func(const long l1, const char *pStr);
VBA 側
Private Declare PtrSafe Function func Lib "test.dll" (ByVal long1 As Long, ByVal str As String) As Long
Sub sub1()
Dim long1 As Long
Dim str As Variant
long1 = 10000 str = "abc" func(long1, str)
End Sub
これでなぜ文字列が渡らないのか?
C++ dll 側の宣言 ★修正版★
extern "C" __declspec(dllexport) long __stdcall func(const char *pStr);
VBA 側
Private Declare PtrSafe Function func Lib "test.dll" (ByVal param As String) As Long
Sub sub1()
Dim long1 As Long
Dim str1 As string
Dim param As Variant
long1 = 10000 str1 = "abc" param = str1 + "," + str(long1) func(param)
End Sub
わけわからんけどこれで解決した。
回答3件
あなたの回答
tips
プレビュー