|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
using EARTHLib;
using UnityEngine;
using System.Resources;
namespace simulation
{
public partial class Frmexe : Form
{
[DllImport("user32.dll")]
private static extern int SetParent(
int hWndChild,
int hWndParent);
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(
int hWnd,
int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool PostMessage(
int hWnd,
uint Msg,
int wParam,
int lParam);
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
private static extern bool SetWindowPos(
int hWnd,
int hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
uint uFlags);
[DllImport("user32.dll")]
private static extern int SendMessage(
int hWnd,
uint Msg,
int wParam,
int lParam);
private const int HWND_TOP = 0x0;
private const int WM_COMMAND = 0x0112;
private const int WM_QT_PAINT = 0xC2DC;
private const int WM_PAINT = 0x000F;
private const int WM_SIZE = 0x0005;
private const int SWP_FRAMECHANGED = 0x0020;
private EARTHLib.ApplicationGE ge = null;
public Frmexe()
{
InitializeComponent();
ge = new ApplicationGE();
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_PAINT, 0);
PostMessage(ge.GetMainHwnd(), WM_QT_PAINT, 0, 0);
SetWindowPos(ge.GetRenderHwnd(), HWND_TOP, 0, 0, (int)this.Width,
(int)this.Height-50, SWP_FRAMECHANGED);
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_SIZE, 0);
ShowWindowAsync(ge.GetMainHwnd(), 0);
SetParent(ge.GetRenderHwnd(), this.Handle.ToInt32());
ResizeGoogleControl();
}
private void Frmexe_Resize(object sender, EventArgs e)
{
ResizeGoogleControl();
}
private void ResizeGoogleControl()
{
try
{
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_PAINT, 0);
PostMessage(ge.GetMainHwnd(), WM_QT_PAINT, 0, 0);
SetWindowPos(ge.GetRenderHwnd(), HWND_TOP, 0, 0, (int)this.Width,
(int)this.Height-50, SWP_FRAMECHANGED);
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_SIZE, 0);
}
catch { }
}
private void Frmexe_FormClosing(object sender, FormClosingEventArgs e)
{
System.Diagnostics.Process[] ge = System.Diagnostics.Process.GetProcessesByName("googleearth");
ge[0].Kill();
}
modified 27-May-16 10:29am.
|
|
|
|
|
You can't; the example shows how to embed a running executable, not how to manipulate its data - it is not loaded as a COM-component (there might not be one) which would allow manipulation of its elements.
You'll find examples on how to add markers in their documentation[^], along with a warning that the API will be gone by the end of this year.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
google earth appilication can show without appication border example minimize,restoredown and close in winform?
|
|
|
|
|
Yes; you'd need to send a (windows) message to the GE application that sets the border. Most examples on embedding a running executable show how to do so.
Example here[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
If you have an issue with the content of a CodeProject article then you should use the forum at the end of the article. However, I note that the author has not been active for some years so it is unlikely that you will get a response..
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
using EARTHLib;
using UnityEngine;
using System.Resources;
namespace simulation
{
public partial class Frmexe : Form
{
[DllImport("user32.dll")]
private static extern int SetParent(
int hWndChild,
int hWndParent);
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(
int hWnd,
int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool PostMessage(
int hWnd,
uint Msg,
int wParam,
int lParam);
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
private static extern bool SetWindowPos(
int hWnd,
int hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
uint uFlags);
[DllImport("user32.dll")]
private static extern int SendMessage(
int hWnd,
uint Msg,
int wParam,
int lParam);
private const int HWND_TOP = 0x0;
private const int WM_COMMAND = 0x0112;
private const int WM_QT_PAINT = 0xC2DC;
private const int WM_PAINT = 0x000F;
private const int WM_SIZE = 0x0005;
private const int SWP_FRAMECHANGED = 0x0020;
private EARTHLib.ApplicationGE ge = null;
public Frmexe()
{
InitializeComponent();
ge = new ApplicationGE();
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_PAINT, 0);
PostMessage(ge.GetMainHwnd(), WM_QT_PAINT, 0, 0);
SetWindowPos(ge.GetRenderHwnd(), HWND_TOP, 0, 0, (int)this.Width,
(int)this.Height-50, SWP_FRAMECHANGED);
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_SIZE, 0);
ShowWindowAsync(ge.GetMainHwnd(), 0);
SetParent(ge.GetRenderHwnd(), this.Handle.ToInt32());
ResizeGoogleControl();
}
private void Frmexe_Resize(object sender, EventArgs e)
{
ResizeGoogleControl();
}
private void ResizeGoogleControl()
{
try
{
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_PAINT, 0);
PostMessage(ge.GetMainHwnd(), WM_QT_PAINT, 0, 0);
SetWindowPos(ge.GetRenderHwnd(), HWND_TOP, 0, 0, (int)this.Width,
(int)this.Height-50, SWP_FRAMECHANGED);
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_SIZE, 0);
}
catch { }
}
private void Frmexe_FormClosing(object sender, FormClosingEventArgs e)
{
System.Diagnostics.Process[] ge = System.Diagnostics.Process.GetProcessesByName("googleearth");
ge[0].Kill();
}
modified 27-May-16 10:30am.
|
|
|
|
|
You aren't reading what they have told you. Ask your question at the end of the article.
This space for rent
|
|
|
|
|
Hello there. We take the example of Bubble Sort Algo.
Time Complexity
Best O(n)
Worst O(n^2)
Space Complexity
Worst O(1)
Let us suppose a simple array contains 25 elements. What does above information mean and how should I visualize it?? Thanks for clearing some basics.
|
|
|
|
|
|
This has nothing to do with C#. You would be better off asking in the Algorithms forum[^].
This space for rent
|
|
|
|
|
Django_Untaken wrote: Let us suppose a simple array contains 25 elements. What does above information mean It will be useless.
|
|
|
|
|
I am running an exe through commandline and getting following output.
C:\Users\sysadmin>C:\Users\sysadmin\Desktop\New_folder\Setup\PatchInstaller.exe --mode=silent
C:\Users\sysadmin Begin Setup
UI mode: Silent
Error : Another instance running, Only a single instance can be run at a time.
Exit Code: 11
i am running this through System.daignostics.process.
My issue is PatchInstaller.exe calling another process and the output of that nested process is what is visible with cmd. but the same result and exit code i am not able to get through Process object of PatchInstaller.exe.
Is there any way of getting output of process running within process?
Following is the code i have tired...
string command = @"C:\Users\sysadmin\Desktop\Setup\PatchInstaller.exe";
string result = string.Empty;
Exitcode = 0;
try
{
Exitcode = 0;
System.Diagnostics.ProcessStartInfo procStartInfo = new ProcessStartInfo();
procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command + " --mode=silent);
System.Diagnostics.Process proc = new Process();
// The following commands are needed to redirect the standard output.
//This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartInfo.ErrorDialog = false;
procStartInfo.UseShellExecute = false;
procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardError = true;
procStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
if (!string.IsNullOrEmpty(domain) && !string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pwd))
{
procStartInfo.Domain = domain;
procStartInfo.UserName = user;
System.Security.SecureString ss = new System.Security.SecureString();
foreach (char c in pwd) { ss.AppendChar(c); }
procStartInfo.Password = ss;
}
// Now we create a process, assign its ProcessStartInfo and start it
proc = System.Diagnostics.Process.Start(procStartInfo);
proc.ErrorDataReceived += delegate(object sender, System.Diagnostics.DataReceivedEventArgs errorLine)
{
if (errorLine.Data != null) result += "error:" + errorLine.Data + "\r\n";
};
proc.OutputDataReceived += delegate(object sender, System.Diagnostics.DataReceivedEventArgs outputLine)
{
if (outputLine.Data != null) result += outputLine.Data + "\r\n";
};
proc.BeginErrorReadLine();
proc.BeginOutputReadLine();
Process[] pname = Process.GetProcessesByName("AdobePatchInstaller");
Process[] processlist = Process.GetProcesses();
foreach (Process theprocess in processlist)
{
Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id);
}
proc.WaitForExit();
}
catch (Exception ex)
{
throw (ex);
}
return result;
modified 26-May-16 6:06am.
|
|
|
|
|
Hi,
I have created an application that sits in the system tray on each PC, which collects system information using WMI and stores it in an SQL DB. I would like to be able to send commands to this application to invoke functions within the application. For example, I could send a shutdown command which when received would fire off a shutdown routine. I would like to be able to send messages to the end user which would fire off a procedure to display that message in a message box.
I was thinking of using the TCP listener class to have the application listen on a specified port, which I could then connect to, and send commands. I would appreciate it if somebody could advise me as to whether this is the right approach or is there an alternative way.
Thanks in advance
Neil (100% human)
modified 26-May-16 4:08am.
|
|
|
|
|
Message Closed
modified 26-May-16 8:59am.
|
|
|
|
|
I nearly bounced this out of moderation as spam! Might be worth editing it to put some descriptive text in that hyperlink
|
|
|
|
|
As Chill says, that looks a lot like a spam post: I'd recommend you edit that and make it clear where the user will end up - I nearly started the process of closing your account after a quick glance! There are some trigger happy members out there - you could get some heavy hits as a spammer if you aren't carefull.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Gee, quite surprised by the comments. I have tried to back up my request with a summary of what I have done and where I want to go for the benefit of anybody wishing to help me.
This is my first time posting in such a forum and not quite sure how I should edit it without making my request vague. Obviously I don't want to be regarded as a spammer so I will attempt to make my request direct.
Thanks for the advice
Neil
|
|
|
|
|
Neil, OG wasn't talking about your posting - that was fine. He was commenting on the link in the other posters reply to you. That could look like spam (it isn't, but we have a lot of trigger happy reviewers).
This space for rent
|
|
|
|
|
As Pete says, they aren't comments on your post. If you look at the page, comments are indented to indicate what is a response to what:
Your post
RickRose0506 - response to you.
CHill60 - response to RickRose0506, responding to you
Me - response to RickRose0506, responding to you
You - response to me, responding to RickRose0506, responding to you
Pete O'Hanlon - response to you, responding to me, responding to RickRose0506, responding to you
Me (this) Response to you, responding to me, responding to RickRose0506, responding to you If you hover your mouse over a subject line, a grey line will appear to the left showing which message it is a response to.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Oh I see. Gee, I just edited my post
Thanks for the update.
Neil
|
|
|
|
|
Not a problem!
We get a lot of spammers coming here (12,000,000 members seems like a good target for spam farmers) and the automated system doesn't catch all of them right off. So when a member sees what looks like spam (and the first response to you did look a lot like it to a casual glance) there is a temptation to immediately hit the "SPAM!" button so that the automated system gets a quick start on recognising the rubbish.
You wouldn't believe how many messages some of these f'wits can post, so it's important to get an early start on them!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Shocking really. Anyway, thanks for not terminating me ![Poke tongue | ;-P](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_tongue.gif)
|
|
|
|
|
What does a site of "HTA, JScript, VBScript and WSC examples" have to do with C#?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I had a minute and tried to post a site that helped me solve this same thing before...
Sorry for all the confusion I deleted my original Post since this effort to try to help has made me come to realize other people need to learn how to do their own digging for information! (So much for trying to be helpful) If you look closer on the site it also contains C# code examples for the kinds of information the original poster is looking for.
Oh and by the way, I am not a spammer!
|
|
|
|
|
Don't let one screw up put you off, we have all done that. Do take the advice given by others and put a little more content in your response if the link does not deal with the specific question. Had you directed to OP to the c# examples in the link it would have been much better.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|