Re: WinAPI Library (Snippets) (548)
Verfasst: 09.10.2010 22:40
Struktur geändert!
Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Funktioniert immer noch nicht.Rudi hat geschrieben:Struktur geändert!
Vermute eher, dass man folgende Werte so verwenden sollte:ts-soft hat geschrieben:hWnd.i und hIcon.i waren richtig aber den Fehler kann ich auch noch nicht erkennen.
Code: Alles auswählen
RunProgram("notepad")
Delay(1000)
hWnd = FindWindow_("Notepad", "Unbenannt - Editor")
GetWindowThreadProcessId_(hWnd, @pId)
hProcess = OpenProcess_(#PROCESS_SET_INFORMATION, #Null, pId)
If hProcess
SetPriorityClass_(hProcess, #BELOW_NORMAL_PRIORITY_CLASS)
CloseHandle_(hProcess)
EndIf
End
; #REALTIME_PRIORITY_CLASS ;Echtzeit
; #HIGH_PRIORITY_CLASS ;Hoch
; #ABOVE_NORMAL_PRIORITY_CLASS ;Höher als normal
; #NORMAL_PRIORITY_CLASS ;Normal
; #BELOW_NORMAL_PRIORITY_CLASS ;Niedriger als normal
; #IDLE_PRIORITY_CLASS ;Niedrig
Code: Alles auswählen
pNr = RunProgram("notepad", "", "", #PB_Program_Open)
Delay(1000)
If IsProgram(pNr) <> 0
pId = ProgramID(pNr)
hProcess = OpenProcess_(#PROCESS_SET_INFORMATION, #Null, pId)
If hProcess
SetPriorityClass_(hProcess, #HIGH_PRIORITY_CLASS)
CloseHandle_(hProcess)
EndIf
CloseProgram(pNr)
EndIf
End
; #REALTIME_PRIORITY_CLASS ;Echtzeit
; #HIGH_PRIORITY_CLASS ;Hoch
; #ABOVE_NORMAL_PRIORITY_CLASS ;Höher als normal
; #NORMAL_PRIORITY_CLASS ;Normal
; #BELOW_NORMAL_PRIORITY_CLASS ;Niedriger als normal
; #IDLE_PRIORITY_CLASS ;Niedrig
Code: Alles auswählen
OpenWindow(0,10,10,200,100,"",#WS_POPUPWINDOW)
Delay(3000)
CloseWindow(0)
End
Code: Alles auswählen
Structure NOTIFYICONDATA_
cbSize.l
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
PB_Alignment1.b[4]
CompilerEndIf
hWnd.i
uID.l
uFlags.l
uCallbackMessage.l
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
PB_Alignment2.b[4]
CompilerEndIf
hIcon.i
StructureUnion
szTip.s{64}
szTipEx.s{128}
EndStructureUnion
dwState.l
dwStateMask.l
szInfo.s{256}
StructureUnion
uTimeout.l
uVersion.l
EndStructureUnion
szInfoTitle.s{64}
dwInfoFlags.l
guidItem.GUID
hBalloonIcon.i
EndStructure
Procedure SysTrayIconBalloon(uId, hWindow, Title$, Message$, timeOut, flags)
Protected nId.NOTIFYICONDATA_
If OSVersion() >= #PB_OS_Windows_Vista
nId\cbSize = SizeOf(NOTIFYICONDATA_)
ElseIf OSVersion() >= #PB_OS_Windows_XP
nId\cbSize = #NOTIFYICONDATA_V3_SIZE
ElseIf OSVersion() >= #PB_OS_Windows_2000
nId\cbSize = #NOTIFYICONDATA_V2_SIZE
Else
nId\cbSize = #NOTIFYICONDATA_V1_SIZE
EndIf
If nId\cbSize
nId\uId = uId
nId\hwnd = hWindow
nId\szInfoTitle = Title$
nId\szInfo = Message$
nId\uTimeout = timeOut
nId\dwInfoFlags = flags
nId\uFlags = #NIF_INFO
nId\uVersion = #NOTIFYICON_VERSION+1
Shell_NotifyIcon_(#NIM_SETVERSION, @nId)
ProcedureReturn Shell_NotifyIcon_(#NIM_MODIFY, @nId)
EndIf
ProcedureReturn #False
EndProcedure
If OpenWindow(0,#PB_Ignore,#PB_Ignore,200,200,"BalloonTip",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
AddSysTrayIcon(0, WindowID(0), ExtractIcon_(0,"explorer.exe",3))
SysTrayIconBalloon(0, WindowID(0),"BalloonTip 1!","BalloonTip wechselt in drei Sekunden!", 100, #NIIF_INFO)
Delay(3000)
SysTrayIconBalloon(0, WindowID(0),"BalloonTip 2!","BalloonTip verschwindet gleich!", 100, #NIIF_WARNING)
Delay(3000)
SysTrayIconBalloon(0, WindowID(0), "", "", 100, #NIIF_NONE)
Delay(1000)
EndIf
End
Code: Alles auswählen
Procedure.s FindAssociatedProgram(File.s)
Protected Result.s = Space(#MAX_PATH)
Protected Error
Error = FindExecutable_(@File, 0, @Result)
If Error <= 32
Select Error
Case #SE_ERR_FNF
Debug "The specified file was not found"
Case #SE_ERR_PNF
Debug "The specified path is invalid"
Case #SE_ERR_ACCESSDENIED
Debug "The specified file cannot be accessed"
Case #SE_ERR_OOM
Debug "The system is out of memory or resources"
Case #SE_ERR_NOASSOC
Debug "There is no association for the specified file type with an executable file"
Default
Debug "Unknown error"
EndSelect
ProcedureReturn ""
EndIf
ProcedureReturn Result
EndProcedure
Code: Alles auswählen
SetComputerName_("Fritz")
;Änderungen werden beim nächsten Neustart des Computers übernommen!
;http://msdn.microsoft.com/en-us/library/ms724930%28VS.85%29.aspx
Code: Alles auswählen
EnableExplicit
Global File$
File$ = OpenFileRequester("", "", "Text (*.txt)|*.txt|Alle Dateien (*.*)|*.*", 0)
If File$
Select ShellExecute_(0, "print", File$, #Null, #Null, #SW_SHOWNORMAL)
Case 0
MessageRequester("Fehler", "The operating system is out of memory or resources.", #MB_ICONSTOP|#MB_TOPMOST)
Case #ERROR_FILE_NOT_FOUND
MessageRequester("Fehler", "The specified file was not found.", #MB_ICONSTOP|#MB_TOPMOST)
Case #ERROR_PATH_NOT_FOUND
MessageRequester("Fehler", "The specified path was not found.", #MB_ICONSTOP|#MB_TOPMOST)
Case #ERROR_BAD_FORMAT
MessageRequester("Fehler", "The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_ACCESSDENIED
MessageRequester("Fehler", "The operating system denied access to the specified file.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_ASSOCINCOMPLETE
MessageRequester("Fehler", "The filename association is incomplete or invalid.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_DDEBUSY
MessageRequester("Fehler", "The DDE transaction could not be completed because other DDE transactions were being processed.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_DDEFAIL
MessageRequester("Fehler", "The DDE transaction failed.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_DDETIMEOUT
MessageRequester("Fehler", "The DDE transaction could not be completed because the request timed out.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_DLLNOTFOUND
MessageRequester("Fehler", "The specified dynamic-link library was not found.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_FNF
MessageRequester("Fehler", "The specified file was not found.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_NOASSOC
MessageRequester("Fehler", "There is no application associated with the given filename extension.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_OOM
MessageRequester("Fehler", "There was not enough memory to complete the operation.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_PNF
MessageRequester("Fehler", "The specified path was not found.", #MB_ICONSTOP|#MB_TOPMOST)
Case #SE_ERR_SHARE
MessageRequester("Fehler", "A sharing violation occurred.", #MB_ICONSTOP|#MB_TOPMOST)
EndSelect
EndIf
;http://msdn.microsoft.com/en-us/library/bb762153%28VS.85%29.aspx
;http://support.microsoft.com/kb/238245