|
I suspect that it is a mismatch in calling conventions.
Your function is declared as PASCAL (which evaluates to __stdcall) but you are trying to call it as Cdecl, which handles the stack a little differently.
Try changing your DllImport to CallingConvention.StdCall
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
If I use StdCall the function will return me IntPtr(0) both in the case the device is connected or disconnected and it is not correct ...
|
|
|
|
|
Griff is right, using the wrong calling convention is likely to corrupt the stack, so you have to take care of that first.
the return value being zero could have many reasons, most probably the function failed to run properly, maybe one of the input parameters has a bad value, your device isn't present, whatever. What would be the expected failure reporting mode of the callee? Does it return zero and set errno or LastError?
Warning: pointers will take 32 or 64 bits depending on your OS and how you build the app.
FWIW: I wrote a little P/Invoke article here[^].
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
YOU ARE RIGHT !!!!
I have mistaken the GUID !!!
Now it works propery !!
|
|
|
|
|
Hi. I am using a C# page to insert data into a table which consists of many columns...
The first column ID which is incremented automatically.
The second column takes input from the front end and is incremented automatically.
Rest columns take input from front end
I use Stored procedure to insert data in the table.
But somehow I find duplicate entries except for first column in the table.
How is this possible? I mean is there an error in my front end coding or is it an error in Sql-server.
Because I tried it myself and it wont allow to enter duplicate values as my logic is perfect and I am inserting values on button click.
But when I fire a query in Sql, it gives me duplicate entries with different ID's only for some records not for all.
Can anybody please help me with that?
|
|
|
|
|
Member 8591985 wrote: is it an error in Sql-server
Certainly not.
Member 8591985 wrote: is there an error in my front end
Possibly.
Member 8591985 wrote: The second column takes input from the front end and is incremented
automatically.
I'm not sure I follow you here.
I suggest you look at your back end code.
|
|
|
|
|
We can't, based on that information.
I would suspect that it is your SP that is at fault, but without seeing it, I can't say what the problem is.
Member 8591985 wrote: it wont allow to enter duplicate values as my logic is perfect
My! Aren't we the lucky one!
Learn to assume that you are wrong: 99.9999% of the time, it will be true. Just because something works when you test it in one specific place, and set of circumstances does not mean it is "perfect" - it just means you haven't found a problem yet.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
OriginalGriff wrote: it just means you haven't found a problem yet.
aka perfect until proven otherwise.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Perfect?? Really??
Everyone thinks their code is perfect, right up until it explodes on a machine that was not your DEV box.
I've got an app I've written going out to 10,800 machines next week. Even though I've tested it to death on a dozen machines, both XP and 7 and had a mini-pilot, I can no longer find anything wrong when the app is used normally and when I intentionally try and break it. Does that mean that my code is perfect?? Hell NO! It just means there's a test case that I haven't thought of yet.
Am I nervous that I have an app going out to so many machines? You bet your ass I am!! Especially so considering this app was comissioned by a VP and has very high visibility.
Chances are VERY good that its your code that's screwed up and there's some misguided step in your logic that you think is right and it's not, or some condition you didn't think of or are not checking for that's causing the problem.
Member 8591985 wrote: I use Stored procedure to insert data in the table. But somehow I find
duplicate entries except for first column in the table.
AND
Member 8591985 wrote: Because I tried it myself and it wont allow to enter duplicate values as my
logic is perfect and I am inserting values on button click.
Case in point. You're obviously doing something very wrong that is never going to work in a multi-user environment. The logic works perfectly IF and only IF there is one person running your frontend. Your code is probably written for that limitation and falls on its face when used by multiple users because it doesn't take into account two people using the code at the exact same time.
You should be asking yourself (and your logic) what would happen if 2 or more users click on this button at the exact same time.
Member 8591985 wrote: How is this possible? I mean is there an error in my front end coding or is it
an error in Sql-server.
An error in SQL Server itself? Most assuredly not. Is there some problem in your stored procedure AND/OR your frontend code? I'd guarantee it!
|
|
|
|
|
Hi All,
I am creating setup project for window application in c#. I want user to enter few details during installation like username/password. Installation will be continued only if these fields are filled. Can anyone tell me how to validate fields during installation.
FYI: I am using standard Setup Project provided by .NET.
Thanks in advance !
Amit
|
|
|
|
|
|
|
Hi there
Im Fairly new to C#.net, In vb i used to use a function called SaveSetting.
Im Aware that no such function in C#.net Exists
is there any way to do this??
Ian
|
|
|
|
|
I don't know what SaveSetting does in VB.NET, but would this[^] help at all?
|
|
|
|
|
My Apologies
SaveSetting is basically a way of saving program settings to the registry so that when the program starts again those setting casn be used.
Eg a user logs in to a program for the first time so i would save their user name to the registry so that when the program starts again it assums the same user wants to logs in a gets the name from the registry and fills it in to the username textbox.
but i use it for all sorts of little bits of data that i need kept out of the way of the scope of the program
If i can't do want ive described in that way id really apreciate some advise on how to achieve the right way.
Many thanks
Ian
|
|
|
|
|
The article I linked to suggests how this can be achieved using C#.
|
|
|
|
|
Looks like SaveSetting was storing data in a file (maybe ini) or database.
You will need to implement similar functionality. Check if you are referring an external dll that contains this method's implementation.
|
|
|
|
|
If you are using C# in WinForms, you have the "Application Settings" facility to help you persist values:[^].
Other strategies, besides Registry manipulation, and Application Settings, include serialization, and deserialization.
CP has very good articles on serialization and de-serialization, just search for them: Mehdi Gholam's recent work on "Fast JSON" is outstanding: but, perhaps more relevant to situations where you need to store and retrieve large amounts of information:[^].
best, Bill
"Our life is a faint tracing on the surface of mystery, like the idle, curved tunnels of leaf miners on the surface of a leaf. We must somehow take a wider view, look at the whole landscape, really see it, and describe what's going on here. Then we can at least wail the right question into the swaddling band of darkness, or, if it comes to that, choir the proper praise." Annie Dillard
|
|
|
|
|
Thanks alot bill
im probably going to have a poke around in application settings, i always hated them in vb thats why i used the reistry, but im going to have a good research into persist values and see what i can learn
thanks again
Ian
|
|
|
|
|
Microsoft doesn't want you storing app settings in the registry anymore. Why would you anyways? The application settings API is about 1% of the work vs. storing stuff in the registry .
|
|
|
|
|
Hi to all
i am creating an application in c# windows using socket programming..
both client and server is working well.
but main concept is when working both client and server
if no process in client program
For Example :
1). idle in gmail
2). like screen saver in windows when no process
at the time in server system shows or alert Like
" The Client Is In IDLE "
how to do this process in c# windows application.. please any body help.. ( sorry for my English )
|
|
|
|
|
|
If you are wanting to know if only your client program is idle and it is WinForms, you can use this[^].
|
|
|
|
|
If you are asking about the server....
If you have open connections and no traffic is received on them after X time (where X depends on your system) then you close the socket.
The client is responsible for detecting the socket close and re-establishing it once it starts doing something.
|
|
|
|
|
hello guys... i have this datagridview inwhich one of the columns is Checkbox column. I have this following code which works well if I put it into Button's Click Event.
<pre>
ArrayList arr = new ArrayList();
for (int i = 0; i < dgStudents.Rows.Count; i++)
{
bool val = Convert.ToBoolean(dgStudents.Rows[i].Cells[0].Value);
if (val)
arr.Add(Convert.ToInt32(dt.Rows[i]["StudentId"]));
}
</pre>
But this code does not help when I wanna check an individual row. Lets say I check/uncheck third row, then how do I know about this change? I tried <b>CellValueChanged</b> but it did not work. thnx for any help.
-- modified 2-Feb-12 4:02am.
|
|
|
|