Next: OpenThread
From: Mike M. on
Never mind I was just being lazy. I can use that volume name fine. Thanks
for the ideas.

"Mike M." <nospam(a)someplace.com> wrote in message
news:%23UfxNBExFHA.3188(a)TK2MSFTNGP14.phx.gbl...
> o.k. Well, I got that all to work nicely using
RegisterDeviceNotification().
> Using HandlerEx instead of Handler like below:
> The only thing remaing is to get the drive letter for the device. The
name
> I retrieve as shown by the code below is some long device name including
the
> GUID but NOT the drive letter. Anyone know how to get the drive letter?
>
> // Extended service handler
> DWORD CServiceModule::ServiceHandlerEx( DWORD fdwControl, DWORD
dwEventType,
> LPVOID lpEventData, PVOID lpContext )
> {
> // Local variables.
> static DWORD CachedState;
> DEV_BROADCAST_HDR *hdr;
> DEV_BROADCAST_DEVICEINTERFACE *devhdr;
> int nameLen;
> CString drive;
>
> // Do not replicate current state.
> // Controls codes greater than 127 are programmer
> // defined service control codes.
> if(( CachedState == fdwControl) && ( fdwControl < 128))
> return NO_ERROR;
>
> // Switch on service control message.
> switch(fdwControl)
> {
> case SERVICE_CONTROL_STOP:
> SetServiceStatus(SERVICE_STOP_PENDING);
> PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
> break;
>
> case SERVICE_CONTROL_DEVICEEVENT: //SERVICE_CONTROL_POWEREVENT:
> {
> switch((int) dwEventType)
> {
> case DBT_DEVICEARRIVAL:
>
> hdr = (DEV_BROADCAST_HDR *)lpEventData;
>
> // DBT_DEVTYP_DEVICEINTERFACE
> // handle event
> if(hdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
> {
> devhdr = (DEV_BROADCAST_DEVICEINTERFACE *)lpEventData;
> nameLen = devhdr->dbcc_size - sizeof(DEV_BROADCAST_DEVICEINTERFACE);
>
> // Services always get unicode strings
> drive = (wchar_t *)&devhdr->dbcc_name;
> }
> return NO_ERROR;
>
> case DBT_DEVICEREMOVECOMPLETE:
> // handle event
> return NO_ERROR;
> }
> } // end switch SERVICE_CONTROL_DEVICEEVENT
> } // end switch fdwcontrol
> return NO_ERROR;
> }
>
>
> "Mike M." <nospam(a)someplace.com> wrote in message
> news:erRAieCxFHA.3112(a)TK2MSFTNGP10.phx.gbl...
> > I am currently trying to get the RegisterDeviceNotification() to work.
On
> > these machines we start our application(service) instead of the shell
> > (explorer) so most features that are part of the shell don't work. That
> is
> > one of the issues I ran into with the Autoplay logic. I had to let
> explorer
> > run to get it to work.
> >
> > "William DePalo [MVP VC++]" <willd.no.spam(a)mvps.org> wrote in message
> > news:uEo5EG9wFHA.1168(a)TK2MSFTNGP15.phx.gbl...
> > > "Hieu Le Trung" <hieult(a)cybersoft-vn.com> wrote in message
> > > news:OdZQ668wFHA.3720(a)TK2MSFTNGP14.phx.gbl...
> > > > So the SHNotifyChangeRegister function will not work on a Service?
> > >
> > > I don't know never having tried it.
> > >
> > > I offered the caution because it is a shell (Explorer) function and
> > > sometimes seemimgly simple things fail to work as you'd expect in a
> > service:
> > >
> > > http://www.microsoft.com/msj/0398/service2.aspx
> > >
> > > Regards,
> > > Will
> > >
> > >
> >
> >
>
>


First  |  Prev  | 
Pages: 1 2 3
Next: OpenThread