Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
setwindowtext (user32)

C# Signature:

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool SetWindowText(IntPtr hwnd, String lpString);

VB.Net Signature:

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function SetWindowText(ByVal hwnd As IntPtr, ByVal lpString As String) As Boolean
End Function

VB Signature:

Declare Auto Function SetWindowText Lib "user32" (ByVal hWnd As IntPtr, ByVal lpstring As String) As Boolean

User-Defined Types:



The handle used cannot be used to make a Form from Form.FromHandle() or from Control.FromHandle().

Tips & Tricks:

Please add some!

C# Sample Code:

SetWindowText(Process.GetCurrentProcess().MainWindowHandle, "Amazing!");

Alternative Managed API:

Do you know one? Please contribute it!

This SetWindowText will set text to the controls(textbox for example) in the same process. If they exist in other processes, use SendMessage instead... - jp

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version