Re: Getting extended error information for PlaySound

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: MikeD (nobody_at_nowhere.edu)
Date: 04/05/04


Date: Mon, 5 Apr 2004 11:08:51 -0400


"Robert" <noone@nowhere.com> wrote in message
news:Ou8whytGEHA.3540@TK2MSFTNGP09.phx.gbl...
> I've seen GetLastError work in VB, it only seems to depend on the API
call.

Not likely. What you may have seen is GetLastError return the error value
of an API call that the VB runtime or a custom control made. The point is,
it probably wasn't an error value for an API function that you called.

> LastDllError didn't return anything useful, either (is there something I
> have to do to make it work, shouldn't it just be set when VB detects an
> error?)

Not all API functions set an error number. VB can't, and doesn't, "detect"
these. The API function must be specifically written to set an error
number. If it does, Err.LastDllError will have the value. There's nothing
special you need to do.

BTW, the PlaySound API function is NOT a function that sets an error value.
If a function sets it, the Platform SDK will indicate so. For example, the
function's documentation will say something like "To get extended error
information, call GetLastError."

>
> Robert
>
> "MikeD" <nobody@nowhere.edu> wrote in message
> news:ODSjmLMGEHA.3404@TK2MSFTNGP10.phx.gbl...
> >
> > "Robert" <noone@nowhere.com> wrote in message
> > news:O24a$sJGEHA.1240@TK2MSFTNGP10.phx.gbl...
> > > Is there any way to get additional information about why a sound could
> not
> > > be played? Is there no device, is it busy, or maybe the file is
corrupt?
> > > Although some sources indicate that GetLastError should provide that
> > > information, I always get a zero on that.
> >
> >
> > You can't call GetLastError in VB (well, you can; it's just useless).
Use
> > the Err object's LastDllError property instead.
> >
> > Mike
> >
> >
>
>



Relevant Pages

  • Re: szPname As String * MAXPNAMELEN (How to declare)
    ... I am using GlobalAlloc API to allocate memeory for structure "MIXERCONTROL" ... And then I used following API function to get the mixer control iformation. ... >> Public szShortName As String ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Which API is better to use and why?
    ... In my case, my code executes API call directly, and soon after that it calls ... GetLastError so I believe it really does not matter which one I use. ... one is and API function while the other is a property on ... > Bryan Stafford ...
    (microsoft.public.vb.general.discussion)
  • Re: Getting extended error information for PlaySound
    ... I've seen GetLastError work in VB, it only seems to depend on the API call. ... LastDllError didn't return anything useful, ...
    (microsoft.public.vb.winapi)
  • Re: With API function, VB freezes up
    ... help section on the Microsoft site likes to put everything in VB.net or C ... you may get better help figuring out API stuff in the ... I haven't been able to just look up an API function ... > I've recently purchased a couple of tutorial books on the API (one by ...
    (microsoft.public.vb.general.discussion)
  • Re: Getting Clipboard data
    ... Does the usage of any api function ... exist in the host language. ... As far as I know the use of the Windows API with VB is identical as its use with VBA. ...
    (microsoft.public.vb.winapi)