Bild auf Start Button änder

  • VB.NET

Es gibt 16 Antworten in diesem Thema. Der letzte Beitrag () ist von Andy16823.

    Bild auf Start Button änder

    Hallo, ich würde gerne via API oder auch ohne den start button ändern. Gibt es da ein Tut oder so

    grüße Andy

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Andy16823“ ()

    es kommt der fehler


    Weitere Informationen finden Sie unter: Ein Aufruf an die PInvoke-Funktion "WindowsApplication39!WindowsApplication39.Form1::ShowWindow" hat das Gleichgewicht des Stapels gestört. Wahrscheinlich stimmt die verwaltete PInvoke-Signatur nicht mit der nicht verwalteten Zielsignatur überein. Überprüfen Sie, ob die Aufrufkonvention und die Parameter der PInvoke-Signatur mit der nicht verwalteten Zielsignatur übereinstimmen.
    Damit injectest du das Bild aber nur in den laufenden Prozess, das bedeutet, du musst immer ein spezielles Programm laufen lassen, dass das macht, sonst ists nach dem nächsten Systemneustart oder nach nem Neustart des Explorers einfach weg.
    Wenn du das so machen willst, die API-Signaturen sind nicht .Net-kompatibel, such dir die richtigen auf pInvoke.net raus.
    also müsste ich es so machen :

    VB.NET-Quellcode

    1. <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    2. Private Shared Function SendMessage(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As IntPtr
    3. End Function

    Andy16823 schrieb:

    also müsste ich es so machen :


    Nein, auf Pinvoke stehen doch die Deklarationen ?(

    VB.Net Signature:

    VB.NET-Quellcode

    1. <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    2. Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
    3. End Function


    oder so:
    Common VB.NET Overloads:

    VB.NET-Quellcode

    1. <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    2. Private Shared Function SendMessage(ByVal hWnd As HandleRef, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr
    3. End Function
    danke, ich hab das nun der fehler kommt nicht aber das bild auch nicht xD hängt das vll an dem Style theme den ich installiert habe ?

    mein code seht nun so aus

    VB.NET-Quellcode

    1. Option Explicit On
    2. Imports System.Runtime.InteropServices
    3. Public Class Form1
    4. <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    5. Private Shared Function FindWindowEx(ByVal hwnd As Long, ByVal hWndChild As Long, ByVal lpszClassName As Int32, ByVal lpszWindow As Int32) As Long
    6. End Function
    7. <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    8. Private Shared Function SetWindowPos(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    9. End Function
    10. <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    11. Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
    12. End Function
    13. <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    14. Private Shared Function LoadImage(ByVal hInst As IntPtr, ByVal lpszName As String, ByVal uType As UInt32, _
    15. ByVal cxDesired As Integer, ByVal cyDesired As Integer, ByVal fuLoad As UInt32) As IntPtr
    16. End Function
    17. Const SW_HIDE As Long = 0&
    18. Const SW_RESTORE As Long = 9&
    19. Const GW_CHILD As Long = 5&
    20. Const SWP_NOSIZE As Long = &H1&
    21. Const WM_CLOSE As Long = &H10&
    22. Const BM_GETIMAGE As Long = &HF6&
    23. Const BM_SETIMAGE As Long = &HF7&
    24. Const IMAGE_BITMAP As Long = &H0&
    25. Const LR_LOADFROMFILE As Long = &H10&
    26. Dim hStart As Long
    27. Dim Flag As Boolean
    28. Dim hOldPic As Long, hNewPic As Long
    29. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    30. hNewPic = LoadImage(0&, Me.TextBox1.Text, IMAGE_BITMAP, 0&, 0&, LR_LOADFROMFILE)
    31. Call SendMessage(hStart, BM_SETIMAGE, IMAGE_BITMAP, hNewPic)
    32. End Sub
    Könnte möglich sein, aber da ich nicht weiss, wie dein Theme-Pack das macht, kann ich das nicht beurteilen.

    Es kann aber auch sein, da es ein veralteter Code ist, das das Handle des Startknopfes bei neueren System so nicht ermittelt werden kann. Guck doch einfach mal wie man unter dem OS das du verwendest an das Handle des Buttons kommt, wenn du das hast kann man weiter guggen.

    Edit:@Andy16823: Hab mal mit Spy++ geguggt, anscheinen kommst du über den Desktop an den StartButton. Musst du dich mal mit FindWindow/FindWindowEx durchhangeln.
    Bilder
    • Unbenannt.JPG

      45,45 kB, 422×294, 119 mal angesehen

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Derfuhr“ ()

    Also ich hab mir mal X-Spy Herunter geladen und folgendes geändert

    VB.NET-Quellcode

    1. Public Class Form1
    2. <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    3. Private Shared Function FindWindow( _
    4. ByVal lpClassName As String, _
    5. ByVal lpWindowName As String) As IntPtr
    6. End Function
    7. <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    8. Private Shared Function SetWindowPos(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    9. End Function
    10. <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    11. Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
    12. End Function
    13. <Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    14. Private Shared Function LoadImage(ByVal hInst As IntPtr, ByVal lpszName As String, ByVal uType As UInt32, _
    15. ByVal cxDesired As Integer, ByVal cyDesired As Integer, ByVal fuLoad As UInt32) As IntPtr
    16. End Function
    17. Const SW_HIDE As Long = 0&
    18. Const SW_RESTORE As Long = 9&
    19. Const GW_CHILD As Long = 5&
    20. Const SWP_NOSIZE As Long = &H1&
    21. Const WM_CLOSE As Long = &H10&
    22. Const BM_GETIMAGE As Long = &HF6&
    23. Const BM_SETIMAGE As Long = &HF7&
    24. Const IMAGE_BITMAP As Long = &H0&
    25. Const LR_LOADFROMFILE As Long = &H10&
    26. Dim hStart As Long
    27. Dim Flag As Boolean
    28. Dim hOldPic As Long, hNewPic As Long
    29. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    30. hStart = FindWindow("Start", "Button")
    31. hNewPic = LoadImage(0&, Me.TextBox1.Text, IMAGE_BITMAP, 0&, 0&, LR_LOADFROMFILE)
    32. Call SendMessage(hStart, BM_SETIMAGE, IMAGE_BITMAP, hNewPic)
    33. End Sub
    So habe nun das Problemm gefunden, der hat die ganze zeit nicht das fenster des Buttons gefunden. Habe nun probiert Ihn erstmal auszublenden. DasFunktionierte nun auch. Nun denke ich der fehler liegt an:

    VB.NET-Quellcode

    1. SendMessage(hStart, BM_SETIMAGE, IMAGE_BITMAP, hNewPic)


    könnte man versuchen ein neues Fenster über das Alte fenster des Buttons zu legen ?