|
better u go for networking projects using socket or remoting
|
|
|
|
|
On Vista, when using its Speech Recognition to control the system when ever there's an ambiguity, Say i have 2 folders called "New Folder" and "New Folder (2)" ...Vista Seems to identify the ambiguity and offers us to isolate both icons by covering them with Green Semi-Transperant Rectangle (Numbered 1 and 2)...the user simply has to say "1" or "2" and the appropriate folder is selected...
I'm currently making a Program that uses Motion Detection to control the mouse...
My Program should also identify all available Windows on screen...(sort of "helps" the mouse, like a guide)
i was wondering if there was any api that could get me the
a) The Coordinates of all Available windows...(EnumWindow then EnumChildWindow ?? )
b) Draw those Green Semi-Transperate Rectangles over them....(Any API? or any code you may have to offer?)
Thank you so much!
modified 20-Oct-19 21:02pm.
|
|
|
|
|
hello, i want to guide dates from Excel to use in C# Form . can you tell me how to do ? or, i should look which books ? thank you
|
|
|
|
|
Microsoft has a download called the tools for office, or something. That's what you need as a bridge between .NET and office, and I'm sure it comes with documentation.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
VSTO visual studio tools for office...
Or, build a c# project( a shared add-in or visual studio add-in and get the interaction between c# and excel)
|
|
|
|
|
hey everyone:
my project comes out this error"could not find installable ISAM" error with Extended Properties=Excel 8.0;HDR=NO;IMEX=1" when i want to read excel .xls file by string OLEDB Connection. but once i take off HDR=NO;IMEX=1. it is able to compliered but it cannt read the first row data. how can i solve the problem. thank you so much
string cnStr = @"Data Source=" + filePathName.ToString() + ";Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;HDR=NO;IMEX=1";
using (OleDbConnection cn = new OleDbConnection(cnStr))
{
using (OleDbCommand cmd = new OleDbCommand())
{
cmd.Connection = cn;
cn.Open();
cmd.CommandText = "select * from [" + tpfileName + "$]";
using (OleDbDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{for (int i = 0; i < dr.FieldCount; i++)
{temp.Add(dr[i].ToString());}
}
}
}
}
|
|
|
|
|
IIRC this is caused by the incorrect version of the Jet engine being installed or possibly the incorrect XL driver for the Jet engine.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi!
I need some pointers to get me started on this problem. I have a university assignment for my database programming class, we're using Oracle 10g. The assignment is all about PL*SQL, but I want to create a .net UI to display data in. I have no problems creating the GUI or using ado.net etc.
The problem is the only way to connect to the Oracle server is via a telnet connection. I've never even attempted to write something like this, so some pointers on how to define and create the connection within my app would be appreciated. Ado.net would need to talk to the oracle server via the telnet connection on certain ports.
Note: the GUI is not actually part of the assignment, I'm doing it out of interest (and perhaps the chance for some extra marks if the lecturer is feeling generous). Cheers.
|
|
|
|
|
I have a com dll written in VC6 c++ and and app written in c#, my question is the following:
I want to be able to return the parameter values from the com dll even if an exception occurs, this works in vb6 as well as in vc6 c++ but for some reason in c# the parameters are returned empty. The parameters that are passed into the com dll are assigned values prior to the exception being thrown so why aren't the values returned to the calling app?
I know, I know why would I want to do something like this? Well, because I want to differentiate between error and alarm conditions without adding additional parameters to my functions. In case of an error condition (fatal) the exception is thrown prior to the return parameters being populated, in the case of an alarm (non-fatal) condition the return parameters are populated prior to the exception being thrown.
C++ COM function definition:
HRESULT GetInfo([out] BSTR* name, [out] BSTR* serialNumber, [out] BSTR* modelNumber);
C# calling routine:
try
{
GetInfo(out name, out serialNumber, out modelNumber, out mac);
}
catch(ComException ex)
{
Debug.WriteLine(SerialNumber);
}
Is this possible? Seems like it should be as it works correctly with VB6 and C++.
|
|
|
|
|
Well, you have an issue with the case of the SerialNumber variable, beyond that, I'm not sure, but I'd suspect the only way to know for sure is to test it. If it doesn't work, it doesn't work. It's all about order of operations, it seems to me.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Forgive my pseudo code, looking back at it I realize it is not accurate and poorly written.
I have made sure that the parameters are populated prior to the exception being thrown, my only guess is that this has something to do with the unmanaged to managed conversion in the case of abnormal function completion (thrown exception).
|
|
|
|
|
Hi,
interesting question. I looked into the C# language specification, and it did not provide an answer. It says:
The following definite assignment rules apply to output parameters. Note the different
rules for reference parameters described in §5.1.5.
• A variable need not be definitely assigned before it can be passed as an output parameter
in a function member or delegate invocation.
• Following the normal completion of a function member or delegate invocation,
each variable that was passed as an output parameter is considered assigned in that execution path.
• Within a function member or anonymous function, an output parameter is considered
initially unassigned.
• Every output parameter of a function member or anonymous function must be definitely
assigned (§5.3) before the function member or anonymous function returns normally.
(My underlining) It does not say what happens by abnormal completion. Here is my best guess:
you are passing a BSTR* which reminds me of how I pass writeable strings to native code, by first creating a StringBuilder with sufficient capacity, then calling the native function, and upon return convert the StringBuilder to a string using its ToString() method. This basically tells me the memory passed to the native function is different from the final result, and that conversion probably does not happen when an exception occurs. Hence my suggestion:
- explicitly create a StringBuilder, with sufficient capacity;
- call the native function
- upon its return, whether normal or abnormal, convert the SB to a string.
Doing so I expect you will get the data you are after.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Because the dll is a com object accessed through the idl interface it will not accept StringBuilder in place of string as the parameter type.
Argument '1': cannot convert from 'out System.Text.StringBuilder' to 'out string'
Am I missing something?
|
|
|
|
|
Sorry, Probably my mistake.
If interfacing to COM does not need an explicit prototype, then you can´t simply change the parameter types; for C# calling non-COM native code I believe it would work the way I had in mind.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:19 AM
|
|
|
|
|
can you use IXMLHTTPRequest in C#?
|
|
|
|
|
Hi!
I am writing a small application which shall communicate with a picaxe microship through the serialport. I have got the communication up and running using the SerialPort class, but got a little disappointed due to the speed.
The picaxe is connected to a potentiometer. The picaxe then reads the value and sends it as one byte(0 - 255)at a given frequency through the serialport to my computer. Then a textbox shows the value.
The problem is that the update speed seems to vary(it seems in the textbox). Sometimes it's pretty much realtime, other times it has up to 2 seconds lag. When it's good it may be good for a long time, a minute or so, and the same if it's slow. I don't know if this can be blamed at Windows(XP), or my programming, or if it's nothing to do with it.
I have heard(read) that the SerialPort class in .NET isn't exactly fast, but honestly, it's just one byte! I have tried many different frequencys for sending the byte at the PICAXE, from 4 times a second to a thousand, but it's like the port is slow.
I have read something about using one thread to scan the port in addition to the one that serves the Window itself, but with the eventhandler for datarecieved I believe this shouldn't be necessary.
I will paste some of my code below, and I will appreciate if someone gives me some feedback.
Thanks you for your time !
Jon, Norway.
The code:
public void initializePort()
{
serialPort.PortName = "COM5";
serialPort.BaudRate = 4800;
serialPort.DataBits = 8;
serialPort.ReadTimeout = 1000;
serialPort.DataReceived += new SerialDataReceivedEventHandler(readPic);
serialPort.Open();
serialPort.DtrEnable = true;
}
public void readPic(object sender, SerialDataReceivedEventArgs e)
{
int fromPic = serialPort.ReadByte();
String line = Convert.ToString(fromPic);
if (display.InvokeRequired)
{
display.Invoke(new MethodInvoker(delegate() { setDispText(line); }));
}
else
{
display.Text = line;
}
}
public void setDispText(String s)
{
display.Text = s;
}
|
|
|
|
|
I ran into issues with performance sending a handful of bytes at a time with custom serial port classes (VS2k3, so no SerialPort class available). I've seen equally miserable performance in an mfc app, so it's not .net specific. Unfortunately I can't recall what I finally did to make it perform acceptably; aside from the fact that I spent several weeks banging my head off the wall over it.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Hi,
IMO DataReceived will not necessarily fire for each byte that is received; basically when one or more bytes are available, you will get an event, and they expect you to obtain all available data each time. If you don't try getting it all, the extra data will sit in the input buffer, and your code will lag getting it out (the ReadExisting method is pretty useful for that provided your data is text, yours isn't); in the end you will loose data unless handshaking has been organized, in which case you only will get a potentially big latency (depending on buffer size).
I do have some more remarks:
1. "from 4 times a second to a thousand" is not compatible with 4800Baud, you need at least 9600Baud to be able to communicate the data at 1000 bytes/s.
2. the line display.Text = line; will never execute since InvokeRequired will always be true
3. if your serial port happens to be a USB-to-serial cable, be aware that those do buffer some characters, so they can transmit data in small packets, making better use of USB bandwidth.
4. I trust you did not enable handshaking and left ReceivedBytesThreshold at 1.
And some suggestions:
1. add a StopWatch to your code, and show both its value (up to the milliseconds) and the incoming data in a Console.WriteLine inside your DataReceived handler; that way you will see how the data comes in, and then decide whether or not it gets processed as it should.
Alternatively, add an incrementing counter to DataReceived or setDispText and have it display in another Label (using Invoke again when in DataReceived).
2. add an ErrorReceived handler, maybe something is going wrong and currently gets ignored.
[ADDED]
If you are mainly interested in the most recent value, there are alternative approaches to reading binary bytes:
1. use SerialPort.BytesToRead and Read(byte[],...) to read what is available, then process the last byte only.
2. instead of wiring DataReceived, just launch a thread that performs a synchronous ReadByte() inside an "eternal" loop, and choose an appropriate ReadTimeout value (maybe 100msec is fine). Such polling will provide better "real-time" behavior (never trust Windows to do any of that) but it will be more expensive though.
[/ADDED]
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Have you tried using BeginReadByte() from SerialPort.BaseStream?
Alternatively, try using SerialPort.Read()
Another possibility is tweaking the SerialPort.BaudRate
|
|
|
|
|
You are definitely not the first to encounter problems trying to interface Windows to some real time device or kit. Having heard/had this complaint many times, though not in .NET (as I've never used .NET), I've seen two possible solutions - none of which I suspect you want to hear.
1. Design your program so that it doesn't rely on real time reading of your port. For instance consider: Do you need to update a window with the potentiomer value 9800/sec when the human eye only scans at a lower frequency? (Can't remember what frequency but 18 or 180 scans/sec seems to come to mind).
2. I had a similar problem trying to make a 'software-scope' out of my old PC and ended up buying VToolsD in order to write a Device Driver and buying a blank PCI card so I could solder on some buffers, 555 timer etc and interface directly to the PCI bus - and my device driver. My device driver - much more responsive than my earlier program attempts - then recorded an array of the sample time and value which it passed to the main program.
|
|
|
|
|
hello ,
my application either run automatically on startup or can be manually executed by user.
is there a way to know who triggered the application ? i want to add a note about it in a log file my application creates.
thanks in advance,
avi
|
|
|
|
|
|
Well I know a dirty workaround: give the auto-startup entry a command line argument and use that.
Doesn't give any kind of guarantee, but it will "usually" be accurate and it's easy to implement.
|
|
|
|
|
|
shabya wrote: know who triggered the application ?
Depends on how you define "who". Computer Name or User Name?
I Love KongFu~
|
|
|
|
|