Disabling of CD autorun. TEMPORARY. [Resolved]

Just starting out? Need help? Post your questions and find answers here.
Michael Korolev
User
User
Posts: 53
Joined: Wed Nov 01, 2006 3:02 pm
Location: Russia/Krasnoyarsk
Contact:

Disabling of CD autorun. TEMPORARY. [Resolved]

Post by Michael Korolev »

Shit, I have this problem.

It is necessary, that at insert of a CD there was no autorun window. But don't disable it from registry, that requires system restart. I need to disable autorun temporarily, while my program is running...

At first I thought, that by PostMessage_() I have to send SHIFT pressing to Explorer. Stupid. After Googling I found that this event is processed by OS, not by explorer just :(.

Where I need to send this message? Or there is another way?
Last edited by Michael Korolev on Sun Sep 02, 2007 7:49 pm, edited 1 time in total.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Michael Korolev
User
User
Posts: 53
Joined: Wed Nov 01, 2006 3:02 pm
Location: Russia/Krasnoyarsk
Contact:

Post by Michael Korolev »

WTF? And how I can translate it to PB? What a stupid programming language... Dear Bill Gates, it was necesary to do it so difficult to understand???
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

Post by bingo »

http://msdn2.microsoft.com/en-us/library/aa969329.aspx

Code: Select all

Global QueryCancelAutoPlay.l

Procedure.l WindowCallback(hwnd,message,wparam,lparam)
result.l=#PB_ProcessPureBasicEvents
Select message
Case QueryCancelAutoPlay
Debug "block autoplay ..."
result=1
EndSelect
ProcedureReturn result
EndProcedure
  
  
If OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
StickyWindow(0,1) 
QueryCancelAutoPlay = RegisterWindowMessage_("QueryCancelAutoPlay")
ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
ButtonGadget(1, 10, 40, 200, 20, "Left Button", #PB_Button_Left)
ButtonGadget(2, 10, 70, 200, 20, "Right Button", #PB_Button_Right)
ButtonGadget(3, 10,100, 200, 60, "Multiline Button  (längerer Text wird automatisch umgebrochen)", #PB_Button_MultiLine)
ButtonGadget(4, 10,170, 200, 20, "Toggle Button", #PB_Button_Toggle)
SetWindowCallback(@WindowCallback())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
8)
["1:0>1"]
Michael Korolev
User
User
Posts: 53
Joined: Wed Nov 01, 2006 3:02 pm
Location: Russia/Krasnoyarsk
Contact:

Disabling of CD autorun. TEMPORARY. [Resolved]

Post by Michael Korolev »

Thanks guys, all works correct.
Michael Korolev
User
User
Posts: 53
Joined: Wed Nov 01, 2006 3:02 pm
Location: Russia/Krasnoyarsk
Contact:

Post by Michael Korolev »

Hmm.. that way works not always :(

More exact way:

Code: Select all

keybd_event_(#VK_SHIFT,0,0,0)
Delay(10000)
keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0)
Works great :)
eJan
Enthusiast
Enthusiast
Posts: 366
Joined: Sun May 21, 2006 11:22 pm
Location: Sankt Veit am Flaum

Post by eJan »

I was playing with..

Code: Select all

Global QueryCancelAutoPlay.l

Procedure.l WindowCallback(hwnd, message, wparam, lparam)
  result.l = #PB_ProcessPureBasicEvents
  Select message
    Case QueryCancelAutoPlay
      ;Debug "block autoplay ..."
      AddGadgetItem(0, 1, "QueryCancelAutoPlay Processed")
      result = 1
  EndSelect
  ProcedureReturn result
EndProcedure


If OpenWindow(0, 0, 0, 220, 200, "QueryCancelAutoPlay", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  StickyWindow(0, 1)
  QueryCancelAutoPlay = RegisterWindowMessage_("QueryCancelAutoPlay")
  EditorGadget(0, 5, 5, 210, 190, #PB_Editor_ReadOnly)
  AddGadgetItem(0, 0, "QueryCancelAutoPlay Waiting...")
  SetWindowCallback(@WindowCallback())
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Yes it work 100%, MSDN: Your application's window must be in the foreground to receive this message.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> MSDN: Your application's window must be in the foreground to receive this message

That is such a pain in the butt. There MUST be a way to do it without the
app's window having the focus. But, I sure can't find a way. Damn MS. :(
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

PB wrote: There MUST be a way to do it without the app's window having the focus.
http://msdn.microsoft.com/en-us/library ... S.85).aspx
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply