Re: szPname As String * MAXPNAMELEN (How to declare)

From: Tom Shelton (tom_at_YOUKNOWTHEDRILLmtogden.com)
Date: 10/07/04


Date: Thu, 07 Oct 2004 00:58:35 -0700

On 2004-10-07, Sakharam Phapale <sphapale@annetsite.com> wrote:
> Hi Tom,
>
> I am using the structure "MIXERLINE" which includes structure "TARGET".
> I have used following statement
> mxl.cbStruct = Len(mxl)
>
> This should gives me 168 as length of structure mxl which is "MixerLine"
> type, but it gives me 68. It doesn't include the string variables.
>
> What is the reason?
>

User Marshal.SizeOf... This will give you the marshaled length, instead
of the .NET length. (Does that makes sense?)

> I am also using following API function which fills detail of mixer control
> in mxl structure which includs short and full name.
>
> ret = mixerGetLineInfo(hMixer, mxl, MIXER_GETLINEINFOF_COMPONENTTYPE)
>
> ret comes as 11. Above function doesn't work.
>

Are you declaring mixerGetLineInfo correctly? Should probably be:

Public Declare Auto Function mixerGetLineInfo Lib "winmm.dll" _
        (ByVal hmxobj As System.IntPtr, _
         ByRef pmxl As MIXERLINE, _
         ByVal fdwInfo As Integer) As Integer
>
><StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
>
> Public Structure Target
>
> Public dwType As Integer
>
> Public dwDeviceID As Integer
>
> Public wMid As Integer
>
> Public wPid As Int16
>
> Public vDriverVersion As Int16
>
><MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAXPNAMELEN)> _
>
> Public szPname As String
>
> End Structure
>

According to MSDN, your wMid should also be Short or Int16. I would
also verify the MMVERSION type - I'm assuming Int16 from the docs, but
you never know...

>
>
><StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
>
> Public Structure MIXERLINE
>
> Public cbStruct As Integer
>
> Public dwDestination As Integer
>
> Public dwSource As Integer
>
> Public dwLineID As Integer
>
> Public fdwLine As Integer
>
> Public dwUser As Integer
>
> Public dwComponentType As Integer
>
> Public cChannels As Integer
>
> Public cConnections As Integer
>
> Public cControls As Integer
>
><MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MIXER_SHORT_NAME_CHARS)> _
>
> Public szShortName As String
>
><MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MIXER_LONG_NAME_CHARS)> _
>
> Public szName As String
>
> Public tTarget As Target
>
> End Structure
>
>
> Waiting for your respose.
>
> Thanks
>
> Sakharam Phapale
>

The rest looks ok at first glance...

-- 
Tom Shelton [MVP]


Relevant Pages

  • Re: Sumproduct in VBA
    ... Thanks a mil Tom and Bob.... ... Yes I have included the string in double quotes. ... SkillLevel is a string, it needs to be in double quotes in the formula: ... empRange As Range) As Variant ...
    (microsoft.public.excel.programming)
  • Re: VERY simple question about "?"
    ... don't see the equivalence between a string delimiter, or a character that signals the beginning of a symbol, and a symbol that is actually productive of something. ... Part of my difficulty understanding you is probably caused by the fact that you seem to try to tackle problems of computer languages with tools from a complete different domain. ... "Tom" - my name can also be called, but when one does so IT doesn't spring into action at all. ...
    (comp.lang.ruby)
  • RE: VBA and SQL dump changing the cell types in other worksheets
    ... Tom thanks very much your suggestion worked. ... Dim cnAssyst_Dev As ADODB.Connection ... Dim strConn As String ... 'Get the start and end dates from Sheet 1 ...
    (microsoft.public.excel.programming)
  • Re: using VLookUp in a VBA program
    ... > I've tried the following as suggested by Tom> ... I would have thought that I am suppose to> include the reference from VBE so that my program can reference the> Analysis Tool, but there are so many packages i am not sure which to> include for the worksheet function. ... >>> Dim WorkSheet As String ...
    (microsoft.public.excel.programming)
  • System.IO.DirectoryNotFoundException: HRESULT: 0x80070003
    ... bstrUrl, String& pbstrServerRelativeUrl, String& pbstrTitle, String& ... Int16& pnCollation, UInt32& pnCollationLCID, Int16& pnCalendarType, ... Int16& pnAdjustHijriDays, Int16& pnAltCalendarType, Boolean& ... Win32 Version: 2.0.50727.42 ...
    (microsoft.public.sharepoint.portalserver)