creightonsmith
New member
- Joined
- Jul 18, 2003
- Messages
- 3
I am using the winmm.dll to do some simple sound recording in vb.net. I am able to get the DLL to work like a charm by sending a string in quotes, but after many different attempts am having no luck when I pass a string variable as described below. Per the MSDN instructions for calling Win32 API functions from .net I have done the following:
First I declare a wrapper class
Imports System.Runtime.InteropServices
Public Class DLLWrapper
Declare API to work with Windows MCI Command
Declare Auto Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal _
lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
End Class
Then I create the class and call the function using the described parameters. If I do this I have no problems:
clsDLLWrapper.mciSendString("save libedit C:\Test.wav", 0&, 0, 0)
When I pass the string variable like this it doesnt work:
Dim strVariable As String
strVariable = "save libedit C:\Test.wav"
clsDLLWrapper.mciSendString(strVariable, 0&, 0, 0)
I have tried a few things including changing the Charset of the function to ANSI, AUTO etc. Any help would be much appreciated as I dont want to have to fix my file path for file recording. Thanks!
First I declare a wrapper class
Imports System.Runtime.InteropServices
Public Class DLLWrapper
Declare API to work with Windows MCI Command
Declare Auto Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal _
lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
End Class
Then I create the class and call the function using the described parameters. If I do this I have no problems:
clsDLLWrapper.mciSendString("save libedit C:\Test.wav", 0&, 0, 0)
When I pass the string variable like this it doesnt work:
Dim strVariable As String
strVariable = "save libedit C:\Test.wav"
clsDLLWrapper.mciSendString(strVariable, 0&, 0, 0)
I have tried a few things including changing the Charset of the function to ANSI, AUTO etc. Any help would be much appreciated as I dont want to have to fix my file path for file recording. Thanks!