0
It is often possible to solve problems such as this by searching, as in:
http://www.altavista.com/web/results?fr=altavista&itag=ody&q=rundll32++shell32+Control_RunDLL+theme+ProcessStartInfo&kgs=1&kls=0
The following works; I tested it.
Dim myThemeProcess As New Process
Dim myTheme As New ProcessStartInfo
Dim filePath As String = "C:\Windows\Resources\Themes\characters.theme"
Dim Arguments As String = "C:\Windows\system32\shell32.dll,Control_RunDLL C:\Windows\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""" + filePath + """"
myTheme.FileName = "C:\Windows\system32\rundll32.exe"
myTheme.Arguments = Arguments
myThemeProcess.StartInfo = myTheme
myThemeProcess.Start()
Accepted 0
I suggest that you not use SendKeys.Send("Enter"); use it only as a last resort. Use the BN_CLICKED as I suggested. I am sorry that I don't know enough about the Display Properties window and the Choose the Theme Dialog box to help much more, but the Spy++ tool that is available from the VS Tools menu can be useful for exploring windows.
0
lolx... its the window where the theme file is opened as you did previously in the code you gave me.
0
I don't know what the Display Properties window is.
0
Hi Sam,
I asked a silly question. The problem is I want to use the method SendKeys.Send("Enter") to the new window which is the Display Properties window but I get the Window handle of Choose the Theme Dialog box. How do I get the Window handle or the Window ID of the Display Properties window?
0
What is the question? I don't see a question. I will assume that you are trying to press a button in the window. You are trying to do it in a manner that beginners try to. It is better to send a BN_CLICKED notification message to the parent form where the button is. You can use Spy++ to get the control id of the button. Understand so far? Probably not; I am probably being too advanced for you. Try to find articles and such about this and if you have questions, create a new thread.
Instead of calling Sleep after calling myThemeProcess.Start(), I think you want to call myThemeProcess.WaitForInputIdle. After that, you can enumerate all top-level windows in the system; the window you want is the window with a process handle (or process id, I forget the details) that matches the process that was started by myThemeProcess.
0
Hi Sam,
I hope you can understand what I am trying to do. I have one last thing to ask you to help me. I am trying to check whether my active window is "Display Properties" but cant get it. I have the code to check out which helps sending the title of active window.
Private Sub OFD_BrowseTheme_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OFD_BrowseTheme.FileOk
Dim filePath As String
filePath = OFD_BrowseTheme.FileName.ToString()
Dim myThemeProcess As New Process
Dim myTheme As New ProcessStartInfo
Dim filePath1 As String = "C:\Windows\Resources\Themes\characters.theme"
Dim Arguments As String = "C:\Windows\system32\shell32.dll,Control_RunDLL C:\Windows\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:""" + filePath + """"
myTheme.FileName = "C:\Windows\system32\rundll32.exe"
myTheme.Arguments = Arguments
myThemeProcess.StartInfo = myTheme
System.Threading.Thread.Sleep(2000)
myThemeProcess.Start()
System.Threading.Thread.Sleep(4000)
SendEnterKey()
End Sub
The code to view the title of active window.
Declare Function GetActiveWindow Lib "user32.dll" () As Integer
Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Integer, ByVal lpString As System.Text.StringBuilder, ByVal cch As Integer) As Integer
Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Integer) As Integer
Private Sub SendEnterKey()
Dim hwnd As Integer = GetActiveWindow
Dim sBuild As New System.Text.StringBuilder(GetWindowTextLength(hwnd) + 1)
GetWindowText(hwnd, sBuild, sBuild.Capacity)
MessageBox.Show(sBuild.ToString)
End Sub
Need help my friend!

0
I think one problem is that we can't use %SystemRoot% in that manner.
The main problem is that you need to pass the arguments as a separate property.
0
Hi Sam,
Thank you very much, you are a life save :).
Can you explain a bit what was the problem with code? I am novice in VB .Net :D
0
Reason might be either the specified file is not there in the location or the path you specified is wrong. Just debug by putting break point and watch the exact location that you are appending there. It will tell you whether the path is Incorrect or the File is not there.