|
I used:
p.CreateNoWindow = true;
www.lovethosetrains.com
|
|
|
|
|
Excellent.. I feel so stupid now. Thanks for your response, worked like a charm.
|
|
|
|
|
Just glad that I can actually be of help.
www.lovethosetrains.com
|
|
|
|
|
I have a DLL written in C and am trying to access it with C#. I had to use DLLImport commands to talk with it and am having a problem. I get "Attemped to read or write protected memory." Now longs in C are 32 bits and longs in C# are 64. Could this be the problem and would just using a Convert.ToInt32(variable) fix it. I tried this when I made the call to the DLL and its still giving me the same error. Even when I declare my variable that I am sending to the DLL function as an int it doesnt work.
-Cal
-- modified at 9:30 Friday 7th October, 2005
|
|
|
|
|
Without real code it's hard to tell whether your DllImport declarations are correct.
But no matter if your C function is using long , int or DWORD parameters, you'll have to declare them as int in C#, because all these values are 32 bit long.
long in C# is 64 bit, adequate for a C function parameter with type QWORD .
Regards,
mav
|
|
|
|
|
C:
typedef void (WINAPI* TDM3TOOLKITShowForm)(long Slot);
C#:
[DllImport("mydll.dll")]
public static extern void ShowForm(int Slot);
private void btnShowtest_Click(object sender, EventArgs e)
{
int Slot = 3;
try
{
ShowForm(Slot);
}
catch (Exception ex)
{
lstBox.Items.Add(ex.ToString());
}
}
here is the code with only names changed for anonymity.
the winapi* part dont make a difference I dont think because I have used other functions out of this DLL. The ones that give me a problem are ones that have longs in them.
-- modified at 10:59 Friday 7th October, 2005
|
|
|
|
|
|
Hi, and thanks for your interest. I have some databound textboxes that are grouped on a number of pages in a tabcontrol. I use a button to call up a dialog box to pull data from a lookup table to speed populating some of the textboxes on the tab control. Updates seem to work fine untill I add some additional code in the Update event to check for null conditions. Then it gets strange, after I fill the textboxes from the lookup dialog I have to click in one (doesn't seem to matter which) of the filled textboxes for the updated information to be posted to the database. I have no code associated with tabcontrol or textbox mouse events on the form.
Code To Open Dialog (Form1)========================================
private void btnLmoLookup_Click(object sender, System.EventArgs e)
{
Form2 LmoLookup = new Form2();
LmoLookup.StartPosition = FormStartPosition.CenterParent;
if( LmoLookup.ShowDialog() == DialogResult.OK )
{
txtBoxDocName.Text = LmoLookup.docFullName;
}
LmoLookup.Dispose();
}
Code To Declare Public Variable (Form2)==================================
public string docFullName
{
get{return this.dsExtPhysLookup1.Tables["tblExternalPhysicians"].Rows[this.listBox1.SelectedIndex]["docFullName"].ToString();}
}
Code To Perform Update (Form1)===========================================
if(this.txtBoxDocName.Text.Trim().Length == 0) {
this.dsPatientIndex1.Tables["tblPatientIndex"].Rows[this.BindingContext[dsPatientIndex1, "tblPatientIndex"].Position]["patientRefDName"] = DBNull.Value;
}
else
{
this.dsPatientIndex1.Tables["tblPatientIndex"].Rows[this.BindingContext[dsPatientIndex1, "tblPatientIndex"].Position]["patientRefDName"] = txtBoxDocName.Text.Trim();
}
this.BindingContext[this.dsPatientIndex1, "tblPatientIndex"].EndCurrentEdit();
this.sqlDataAdapter2.Update(this.dsPatientIndex1);
-- modified at 8:53 Friday 7th October, 2005
|
|
|
|
|
I am going to write an application that will be controlling hardware through two RS-232 ports. The code that drives each port will be doing the exact same thing, but the actions will be totally independent of one another. What I need to determine is how to make the code run simualtaneously for each COM port, but independent of the other. My plan is to have a GUI the has two frames on the screen. In the left frame will be the code that interfaces with port COM1 and in the right frame will be the code that interfaces with port COM2. These will be asynchronous events and will basically be running independent of one another except that a signle application will encapsulate all of th code.
Overall, the theory behind what I am doing is pretty easy and I have a lot of experience wirting drivers for hardware, but I need to have mulitple instances running simultaneously in a single application. That is the part I have no expeience and am stuggling with. Any advice, links to tutorials,code ex., etc would be a great help.
In a nut shell, I want to be able to take a single application to operate some hardware, then be able to run it two, there, four, even more times within the same application at the same time.
Terry Jones
|
|
|
|
|
Put the rs232 code into a thread, and run 2+ seperate instances of it.
|
|
|
|
|
You should use .NET 2.0, it already contains all the code for interfacing with COM ports. .NET 1.1 does not provide this.
|
|
|
|
|
Hi all,
I am a Beginner to c#.
I Need to convert array of byte data type to string. How to do this..
ex:
byte[] bytes = new byte[1000];
this bytes get filled up. Now I need to convert to string.
How to do this..
|
|
|
|
|
Hello
You use the next code:
byte[] bytes = new byte[] { 0x41, 0x42, 0x43, 0x44, 0x45 };
string str = System.Text.Encoding.ASCII.GetString( bytes );
System.Diagnostics.Debug.WriteLine( str );
With best regards,
Andrew Kirillov, MCP x 3
Prize winner, August 2005
|
|
|
|
|
hi Kirillov,
Thanks a lot..
Worked and my problem is solved..
Have a nice day..
Shiva P
|
|
|
|
|
Can somebody point me to LDAP code for authenticating a user through LDAP or active directory.
Thanks in Advance.
Ramendra Kotharkar
Ramendra K
|
|
|
|
|
DirectoryEntry entry = new DirectoryEntry("LDAP://testdomain/DC=testdomain", "testdomain/" + textUser.Text, textPassword.Text);<br />
<br />
Object obj = entry.NativeObject;<br />
DirectorySearcher search = new DirectorySearcher(entry);<br />
search.Filter = "(SAMAccountName=" + textUser.Text + ")";<br />
search.PropertiesToLoad.Add("cn");<br />
SearchResult result = search.FindOne();<br />
<br />
if (null == result)<br />
{<br />
.<br />
.<br />
.<br />
}
This only works with AD, by the way: if you find that works with LDAP, please let me know
|
|
|
|
|
Hi
"%FrameworkSDKDir%\bin\resgen.exe" "$(ProjectDir)UserMessages.txt" "$(ProjectDir)UserMessages.resources"
I have added the above line in my post build event. It throws up a post build error.
(A tool returned an error code from the build event).
When i run the above command (replacing Project dir with directory path) from .net command prompt it works fine and returns the following message.
Read in 2 resources from 'c:\TestProject\UserMessages.txt'
Writing resource file... Done.
Thanks in advance.
|
|
|
|
|
Is there any wndows api or hook by which i can get application wide events in a windows application?
Please help me guys, i am stuck in a project.
Thanks in advance.
|
|
|
|
|
|
Hi
I was wondering if anyone could offer some advice on authenticating a .NET application with LDAP. The code seems to work fine with AD, but fails with LDAP. Also, I have a Java App that can do this just fine, but somehow the solution with .NET eludes me!
(extract)
DirectoryEntry entry = new DirectoryEntry("LDAP://testdomain/DC=testdomain", "testdomain/testuser", textPassword.Text);<br />
<br />
Object obj = entry.NativeObject;<br />
DirectorySearcher search = new DirectorySearcher(entry);<br />
search.Filter = "(SAMAccountName=testuser)";<br />
search.PropertiesToLoad.Add("cn");<br />
SearchResult result = search.FindOne();<br />
<br />
if (null == result)<br />
{<br />
.<br />
.<br />
.<br />
}
The test PC runs on a Windows XP box with .NET Framework 1.1, and is bound to whichever server we're testing on at the time.
The authentication server is a Mac OS X 10.4 server running LDAPv3 (I believe built on OpenLDAP, and should be similar in every way).
Any suggestions?
(or anyone with a Linux OpenLDAP domain out there?)
|
|
|
|
|
|
Thanks - have you perhaps got a link to it?
|
|
|
|
|
|
how to add an event 2 a graphics object?
|
|
|
|
|
Can you post an example of the code you are wishing to "add an event" for so we can see what it is yo're trying to do?
|
|
|
|