|
Using SendMessage API to control external app:
have an external application that I need to be able to control. I've tried using SendKeys but due to the obvious limitations of this function the behavior is erratic. I know you can do this using the SendMessage API ( find the handle of the external application's window ,first ) ,but I'm not sure how to do it.
can you provide the sameple code to me ,please?
you are welcome to visit my blog
|
|
|
|
|
By trying using SendMessage API i got:
C:\Projecti\test\Form1.cs(77): 'System.Windows.Forms.Control.SendMessage(int, int, int)' is inaccessible due to its protection level
This API is from Platform SDK and i think it doesn't support in C#.
To get handle, you can call GetActiveWindow or FindWindow
|
|
|
|
|
I can do it now
I can use FindWindow,GetWindow and SendMessage to send message to a notepad app,just like this:
hWnd1 = FindWindow(null, "Untitled - Notepad");
hWnd2 = GetWindow(hWnd1, GW_CHILD);
sText =this.textBox1.Text;
SendMessage (hWnd2, WM_SETTEXT,sText.Length, sText);
but I don't know how to excute a word app's dictate by another app,help me please ,thank you!
you are welcome to visit my blog
|
|
|
|
|
I'm learning to program in C# w/ VisualStudio.NET 2003.
I've just bought a MCAD Certification book (70-316) Kalani.
Just started reading the self-assesment portion:
Here's some questions...
What the heck is the difference between the Framework SDK and VisualStudio.NET??
How do I "practice" working with the Framework SDK, as suggested in the book??
I know I'll get hammered for this Q. but so what...would I know the difference just by looking at the screen?
--thanks
|
|
|
|
|
Anonymous wrote:
What the heck is the difference between the Framework SDK and VisualStudio.NET??
The Framework SDK can be downloaded without buying VS.NET. It comprises everything you need to write programs in C# using a text editor and the command line, or a third party IDE, of which one or two exist ( free ware ).
Anonymous wrote:
How do I "practice" working with the Framework SDK, as suggested in the book??
Write code.
Anonymous wrote:
I know I'll get hammered for this Q. but so what...would I know the difference just by looking at the screen?
The difference between what ? The Framework SDK and VS.NET ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I know I'll get hammered for this Q. but so what...would I know the difference just by looking at the screen?
The difference between what ? The Framework SDK and VS.NET ? YES.
The study guide said make sure you practice with BOTH VS.Net and
The Framework SDK.
|
|
|
|
|
Anonymous wrote:
The difference between what ? The Framework SDK and VS.NET ? YES.
OK, then I did answer that, and rgraham explained it in more depth than I did.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Visual Studio NET is an Integrated Development Environment - an environment that supports creating applications by providing graphical tools, debugging facilities, project management tools etc.
The NET framework is a family of classes that provide libraries of functions that provide the foundation of the programs you create using NET languages.
The NET framework is an integral part of any application you create. Visual Studio is an environment that assists you in creating those applications.
|
|
|
|
|
Thanks-- that was an excellent explanation...
|
|
|
|
|
Example in psudocode
new myHugeObject HugeObject();
.....
myHugeObject = null; //no GC between this statement and the next
fixed int i;
//CLR calls garbage collection here
In this case will any more memory actually be made available to the application (would require a c/c++ style linked list style heap), or will all the memory freed from MyHugeObject and any other GCed variables be unavailable until i goes out of scope?
I'm assuming it would be the latter, in which case prior to allocating fixed variables with long lifetimes might be one of the handful of exceptions to the general rule against forcing manual GCs.
|
|
|
|
|
The CLR uses a special large object heap to handle large objects, so doing a collection probably wouldn't have the effect you are expecting.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
Forgot about that. I'm more interested in the behavior of the GC itself than in a particular circumstance that would cause it though. modified example.
//allocate lots of small-medium sized objects, and release them all at once (ie stuff them into a container, etc)
fixed int i;
//CLR calls garbage collection here
If the CLR is smart enough to do a GC before creating fixed variables this wouldn't matter, but if the freed objects were around long enough to become Gen2 and needed finalizing there'd be a major performance hit in a potentially unneeded call, so I doubt it would.
|
|
|
|
|
In your example, you're creating an int32 after you allocate and release a large number of objects. AFAIK, in the IL code thats generated, the space for the int32 value type is allocated at the beginning of the method its declared in, not when your code specifies its creation, I THINK! I haven't verified this with a test though...
If this is indeed the case, your question isn't valid because it describes a situation that never happens.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm not sure how it would affect it. Probably the best way to figure it out is to fire up windbg and sos to see where all the allocations are.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
I don't think having fixed variables affects collection of other objects. The GC walks the heap and traces roots to those objects. In your case, if the GC happened at the point you indicated, then it will notice that HugeObject has no outstanding references and hence will garbage collect it.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
You've misunderstood my question. My concern was that the fixed variable would be placed after HugeObject in memory. Since the fixedvar can't be moved, freeing HugeObject wouldn't actaully provide any more memory to be used without the memory manager using a freelist type structure to allocate memory in the space between the nonGCed objects and the fixedvar.
|
|
|
|
|
dan neely wrote:
My concern was that the fixed variable would be placed after HugeObject in memory
No, it wouldn't. HugeObject would end up on the Large Object Heap. Your int would not be allocated on the same heap.
Also, fixed can only allocate pointers. You can't use it to allocate an int , but you can use it to allocate a pointer to an int . In order for the pointer to be valid, the fixed statement pins the target of the pointer so the GC can't move it. Once the fixed statement is no longer in scope, the pinned object is released.
Point pt = new Point();
fixed ( int* p = &pt.x )
{
*p = 1;
}
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In client and server environment. My client make a request to the server, then server need to create a new Appdomain object "ad", then create an object "so" from this new Appdomain for client to use, My questions are:
(1)How to create a new channel and register this server object "so" in the new domain, I went through all the Appdomain class members, still don't have a clue.
I am thinking to use "ChannelServices.RegisterChannel(new IpcChannel(portName))", but how to associate this to new Appdomain object "ad" or "ad" event(I am guessing)?
(2)If (1) succeed, how I let my client know or pass the reference of new registered object to the client since client won't be able to know the channel information in advance?
You help is highly appreciated!
Hang
|
|
|
|
|
sir, i'm learning vb.net,c#.net in a institute.
can i got a job with 50,000(Rs.) salary or is there any wanted.
i want to do my project in .net
write me any concept
|
|
|
|
|
Anonymous wrote:
sir, i'm learning vb.net,c#.net in a institute.
Good
Anonymous wrote:
can i got a job with 50,000(Rs.) salary or is there any wanted.
That's about US$1,104 a year. It sounds like you're worth it.
Anonymous wrote:
i want to do my project in .net
Good
Anonymous wrote:
write me any concept
You sound like a real candidate for www.rentacoder.com. They get people with little skill in the third world, and pay them badly, to write bad code. You should check it out.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I've developed a simple C# program (for PocketPC), and It sometimes crashes with an unhandled exception... and I thing it is related to UI matters. The message is this:
Exception
Application::Run+0xf
Form1::Main+0xa
Mi application read info from serial port (from a GPS), with this event handler:
private void OnDataReceived(object sender, SerialDataReceivedEventArgs e) <br />
{ <br />
while(port != null && port.BytesToRead > 0) <br />
{ <br />
int Cnt = port.Read(portBuf, portPos, 1); <br />
<br />
if (Cnt != 0) <br />
{ <br />
if (portBuf[portPos] == '\n') <br />
{ <br />
string sentence = Encoding.ASCII.GetString(portBuf, 0, portPos-1); <br />
AddResult(sentence); <br />
<br />
portPos = 0; <br />
} <br />
else <br />
{ <br />
portPos++; <br />
} <br />
} <br />
}
} <br />
<br />
After much investigation, now I am able to cause that exception by clicking a button. The code is this, simple one:
<br />
private void btnClosePort_Click(object sender, System.EventArgs e) <br />
{ <br />
Cursor.Current = Cursors.WaitCursor; <br />
<br />
Thread.Sleep(1000); <br />
<br />
try <br />
{ <br />
port.DataReceived -= new SerialDataReceivedEventHandler(OnDataReceived); <br />
Thread.Sleep(1000); <br />
<br />
port.Close(); <br />
port.Dispose(); <br />
port = null; <br />
} <br />
catch (Exception ex) <br />
{ <br />
AddResult("-->Failure"); <br />
AddResult(ex.ToString()); <br />
} <br />
<br />
Cursor.Current = Cursors.Default; <br />
<br />
AddResult("-->Closed"); <br />
}<br />
Notes: AddResult simple does add strings into a ListBox.
The really strange thing is this: if I remove the AddResult(sentence) call in "OnDataReceive", the exception is not thrown.
Could it be any bug related to UI ?
My hardware: iPAQ 2100 , Windows Mobile 2003 SE
Hope you can help me
Thanks to all!
|
|
|
|
|
the ShortCut work fine, you just put & charecter on text, and use Alt key
with letter.
but i have problam:
we have a form with English Input textbox, but the ShortCut is on another
InputLanguage.
in MSAccess the shortcut work with 2 Language, but in dotnet the shortcut
must be on the same
language as InputLanguage!
i try to find event, or windows msg, to trap the point befor DotNet search
after control with shortcut,
but it's not work.
please help!
|
|
|
|
|
Assumption: both my server and client will use
System.Runtime.Remoting.RemotingConfiguration.Configure(configFile);
to read configuration file
Following are couple of ways I tried, none of them works:
(1)SERVER side:
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="ipc" portname="IpcChannelOne">
<channel ref="ipc" portname="IpcChannelTwo">
<service>
<wellknown type="MyServer.RemoteObjectOne, ServerAssembly"
="" objecturi="RemoteObjectOne.rem" mode="Singleton">
<wellknown type="MyServer.RemoteObjectTwo, ServerAssembly"
="" objecturi="RemoteObjectTwo.rem" mode="Singleton">
CLIENT side:
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown type="MyInterface.IRemoteObjectOne,
InterfaceAssembly"
="" url="ipc://IpcChannelOne/RemoteObjectOne.rem">
<wellknown type="MyInterface.IRemoteObjectTwo,
InterfaceAssembly"
="" url="ipc://IpcChannelTwo/RemoteObjectTwo.rem">
(2)SERVER side
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="ipc" portname="IpcChannelOne">
<service>
<wellknown type="MyServer.RemoteObjectOne,
ServerAssembly"
="" objecturi="RemoteObjectOne.rem" mode="Singleton">
<channels>
<channel ref="ipc" portname="IpcChannelTwo">
<service>
<wellknown type="MyServer.RemoteObjectTwo,
ServerAssembly"
="" objecturi="RemoteObjectTwo.rem" mode="Singleton">
CLIENT side:
no change
(3)SERVER side:
<configuration>
<system.runtime.remoting>
<application>
<service>
<channels>
<channel ref="ipc" portname="IpcChannelOne">
<wellknown type="MyServer.RemoteObjectOne, ServerAssembly"
="" objecturi="RemoteObjectOne.rem" mode="Singleton">
<service>
<channels>
<channel ref="ipc" portname="IpcChannelTwo">
<wellknown type="MyServer.RemoteObjectTwo, ServerAssembly"
="" objecturi="RemoteObjectTwo.rem" mode="Singleton">
CLIENT side:
no change
(4)SERVER side
<configuration>
<system.runtime.remoting>
<application>
<service>
<channels>
<channel ref="ipc" portname="IpcChannelOne">
<wellknown type="MyServer.RemoteObjectOne, ServerAssembly"
="" objecturi="RemoteObjectOne.rem" mode="Singleton">
<channels>
<channel ref="ipc" portname="IpcChannelTwo">
<wellknown type="MyServer.RemoteObjectTwo, ServerAssembly"
="" objecturi="RemoteObjectTwo.rem" mode="Singleton">
CLIENT side:
no change
Please advise what is the right way to create both client and server side
configuration files.
Your help is highly appreciated!
Hang
Hang
|
|
|
|
|
i developed an applicatin in c#.net using the bandobjects. its a kind of deskbar like the google deskbar.
when i am trying to build its installer its doesnt register the dll which need to be registerd and if i register those twoo dll's through command line with "regasm" it starts working.
can anybody pls help me to know how can i run a batch file through a installer or is there any other way to do it.
i tried all the option available with the .net setup like the vscom register .
Thanks in advance to help me.
|
|
|
|
|
I'm not sure why the setup is not correctly registering the assemblies in the first place. First I would google and see if you can find more information.
But troubleshooting installs can be very complicated.
Alternatives are:
1) You can add an Installer class to the setup that uses conventional C# or VB.NET code to shell out the command line to register the assemblies. See the MSDN or search for articles on using Installer classes.
One disadvantage to using this approach is that you cannot rollback the process in an uninstall. By the time the Installer class code runs during an uninstall, the assemblies will already be gone, so regasm run from a commandline will not be able to unregister them. So the registry entries for the assemblies will be left on the machine.
2) You can accomplish a clean uninstall by not using regasm at all, but instead by creating all the equivalent registry entries directly. In this approach you must first determine all of the registry operations that are created during a regasm registration of the assembly. Then you add these keys to be written during during an install, and deleted during an uninstall. This approach is tedious and more difficult but it does result in a more professional setup that uninstalls cleanly. The trick is determining all the registry keys. There are various tools available that will "spy" on the registry and log any changes that can help you do this. But if you go this route, you must be careful to test, test and test again!
|
|
|
|