473,395 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

waveOutGetDevCaps in .net (Upgrade from VB6)

Howdy,

I've tried everything (but the right thing obviously) to get the
following to work, I'm sure it has something to do with the changes
from VB6 to .net, but sure has me stumped, any suggestions? It's not
populating the WAVEOUTCAPS structure, and GetLastError returns "Error
#126"

Thanks!

Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Integer
Declare Function waveOutGetDevCaps Lib "winmm.dll"_
Alias "waveOutGetDevCapsA" (ByVal uDeviceID As_
Integer, ByVal lpCaps As WAVEOUTCAPS, ByVal_
uSize As Integer) As Integer

(snip)

Private Const MAXPNAMELEN = 32

Structure WAVEOUTCAPS
Public wMid As Int16 ' integer
Public wPid As Int16 ' integer
Public vDriverVersion As Int32 ' long
<VBFixedString(MAXPNAMELEN)> Public szPname As String
Public dwFormats As Int32 ' long
Public wChannels As Int16 ' integer
Public dwSupport As Int32 ' long
End Structure

(snip)

Public Shared Sub GetWaveOutDevices()

Dim NumDevs As Integer
Dim WaveFormat As WAVEOUTCAPS
Dim i As Integer
Dim result As Integer

NumDevs = waveOutGetNumDevs()

For i = 0 To NumDevs - 1

result = (waveOutGetDevCaps(i, WaveFormat,
Len(WaveFormat)))
'(result = 0)
Next

End sub
Nov 20 '05 #1
2 3172
Hi
This is a long shot but try taking the alias out of the api declare
statement ( I cant remember where I read this, and haven't tried it myself )

Regards
James

"LongShotBuddy" <gr**@truckmaster.com> wrote in message
news:38**************************@posting.google.c om...
Howdy,

I've tried everything (but the right thing obviously) to get the
following to work, I'm sure it has something to do with the changes
from VB6 to .net, but sure has me stumped, any suggestions? It's not
populating the WAVEOUTCAPS structure, and GetLastError returns "Error
#126"

Thanks!

Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Integer
Declare Function waveOutGetDevCaps Lib "winmm.dll"_
Alias "waveOutGetDevCapsA" (ByVal uDeviceID As_
Integer, ByVal lpCaps As WAVEOUTCAPS, ByVal_
uSize As Integer) As Integer

(snip)

Private Const MAXPNAMELEN = 32

Structure WAVEOUTCAPS
Public wMid As Int16 ' integer
Public wPid As Int16 ' integer
Public vDriverVersion As Int32 ' long
<VBFixedString(MAXPNAMELEN)> Public szPname As String
Public dwFormats As Int32 ' long
Public wChannels As Int16 ' integer
Public dwSupport As Int32 ' long
End Structure

(snip)

Public Shared Sub GetWaveOutDevices()

Dim NumDevs As Integer
Dim WaveFormat As WAVEOUTCAPS
Dim i As Integer
Dim result As Integer

NumDevs = waveOutGetNumDevs()

For i = 0 To NumDevs - 1

result = (waveOutGetDevCaps(i, WaveFormat,
Len(WaveFormat)))
'(result = 0)
Next

End sub

Nov 20 '05 #2
On 2004-02-17, LongShotBuddy <gr**@truckmaster.com> wrote:
Howdy,

I've tried everything (but the right thing obviously) to get the
following to work, I'm sure it has something to do with the changes
from VB6 to .net, but sure has me stumped, any suggestions? It's not
populating the WAVEOUTCAPS structure, and GetLastError returns "Error
#126"

Thanks!

Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Integer
Declare Function waveOutGetDevCaps Lib "winmm.dll"_
Alias "waveOutGetDevCapsA" (ByVal uDeviceID As_
Integer, ByVal lpCaps As WAVEOUTCAPS, ByVal_
uSize As Integer) As Integer
Your declate for waveOutGetDevCaps is wrong... Should be:

Declare Auto Function waveOutGetDevCaps Lib "winmm.dll" _
(ByVal uDeviceID As Integer, _
ByRef lpCaps As WAVEOUTCAPS, _
ByVal uSize As Integer) AS Integer
(snip)

Private Const MAXPNAMELEN = 32

Structure WAVEOUTCAPS
Public wMid As Int16 ' integer
Public wPid As Int16 ' integer
Public vDriverVersion As Int32 ' long
<VBFixedString(MAXPNAMELEN)> Public szPname As String
Public dwFormats As Int32 ' long
Public wChannels As Int16 ' integer
Public dwSupport As Int32 ' long
End Structure

Your Structure is wrong as well.. VBFixedString is not for interop.. And
you'll need to set the CharSet attribute on the structure as well.
Also, it looks like you forgot a field.

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Structure WAVEOUTCAPS
Public wMid As Short
Public wPid As Short
Public vDriverVersion As Integer

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAXPNAMELEN)> _
Public szPname As String

Public dwFormats As Integer
Public wChannels As Short
public wReserved1 As Short
public dwSupport As Integer
End Structure
(snip)

Public Shared Sub GetWaveOutDevices()

Dim NumDevs As Integer
Dim WaveFormat As WAVEOUTCAPS
Dim i As Integer
Dim result As Integer

NumDevs = waveOutGetNumDevs()

For i = 0 To NumDevs - 1
result = (waveOutGetDevCaps(i, WaveFormat, Marshal.SizeOf(WaveFormat))) '(result = 0)
Next

End sub

HTH
--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
"For a moment, nothing happened. Then, after a second or
so, nothing continued to happen. "
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: frank brown | last post by:
When I run the vstudio.net upgrade wizard on a VB6 project, it bombs with the following error: "Upgrade failed: Exception occurred: The referenced component ListView is missing a design time...
1
by: Denman | last post by:
Hi. Can someone point me in the right direction to help estimate the cost to upgrade from VB6. We have 8 VB6 licenses. All the box's are running VB6 and NT 4. We also are using VSS 5.0. We...
7
by: DaVBGuy | last post by:
I'm currently using VB 6 for windows based apps. Should I make the jump to VS.2003 now, or should I wait till (the final) VS.2005 release comes out later this year. If I have not started...
4
by: MadCrazyNewbie | last post by:
Hey Group, I have a VB6 Project im trying to use with VB.Net, It lets me open it and the Upgrade Wizard Launches I click next Select EXE and Click Next Again, the it errors with: "Upgrade...
2
by: Shailja | last post by:
I read lots of stuff on MSDN relating to upgrading a COM Dll build using VB6 to VB.Net. Its seems to be a very easy task. As per few articles when we open vb6 application in .Net framework upgrade...
3
by: Robby | last post by:
Hello I posted this to vb.upgrade but I have had no response for three days so I am giving this forum a try. I have almost completed Francesco Balena's "Programming Microsoft Visual Basic...
0
by: vul | last post by:
I have a pretty big VB6 project. Every day I'm getting requests from my boss to add some new features or change existing ones. So I do not see any easy way to rewrite an existing project using...
1
by: NeedHelp | last post by:
I am upgrade a VB6 Program (ok no wise cracks) and I get 100's of "Event may fire when form is initialized" This is despite using the "Private IsInitializing As Boolean" suggested in then...
2
by: js | last post by:
I newly installed Windoz Vista on my machine. I am trying to upgrade several VB6 ACTIVEX DLLs to VB.net. I tried to open the original VBG in Visual Studio 2005. The VB Upgrade Wizard was...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.