|
My guess is that even though you have only one DeviceInfo, you need to make an array to pass to the function since that is what it expects.
|
|
|
|
|
Hi All,
Thanks for your suggestions!
@Gideon: I tried as you suggested, making an array. Now weirdly, the program ends abruptly at the point of function-call (where the Exception was occurring earlier.)
@oobimoo: Well, I didnt know that one cant declare a struct in C#...For me, I didnt get an error yet. This is what i am doing:
public struct device_info_t
{
public int size;
.......
}
@led mike:
I am not so sure how the PInvoke is done. This is how its done in my project. Is there any better way?
[System.Runtime.InteropServices.DllImport("device", EntryPoint="GetSearchResults", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLastError=true)]
public static extern int GetSearchResults(int handle, ref device_info_t results, int _count);
Any suggestion guys?
Whats still very weird, why is this AccessViolationException occurring?
Thanks a lot!
|
|
|
|
|
You can declare a structure in C#, but if you are going to use it for PInvoke, you need to use an attribute to make sure it gets laid out correctly. It should be:
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
public struct device_info_t
{
public int size;
....
}
Then make sure you declare the fields in the structure in the same order as in the header file.
Also, I would try changing the signature of the function definition. Even if the size_t structure fits in an integer, I would go ahead and define it anyway to be safe.
Original:
int GetSearchResults(const handle_t handle, device_info_t results[], const size_t count);
C#
int GetSearchResults(IntPtr handle, device_info_t results[], size_t count);
|
|
|
|
|
Hi all,
I use C# and SQL Server,I make DataSet by QueriesTableAdapter but I don't know how can use DataSet in C# program when i use Wizard DataSet
|
|
|
|
|
What exactly do you wanna do?
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I make DataSet By Wizard but when I want to use this DataSet in my application,C# does not know DataSet and not show method and properties
|
|
|
|
|
mghiassi wrote: C# does not know DataSet and not show method and properties
So you should go back to your beginners books and tutorials until you understand how to add new files and classes to a project before you start messing around with DataSets.
led mike
|
|
|
|
|
Perhaps you should first ask yourself "why" to use a DataSet in your application.
|
|
|
|
|
|
It depends on the application that have created your dat file.
Is-it your own application ? did you use serialization ?
...
|
|
|
|
|
Hi all I need to get the source ip from a udp header I read udp data in the following way.
byte[] data = null;
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, port);
Socket newsock = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
newsock.Bind(ipep);
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
EndPoint tmpRemote = (EndPoint)(sender);
DateTime file_time = DateTime.Now;
int file_counter = 0;
while(true)
{
int counter = 0;
data = new byte[2048];
Console.WriteLine();
Console.WriteLine("Waiting for a client...");
recv = newsock.ReceiveFrom(data, ref tmpRemote);
Does anybody know how to do this
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Stephen Lintott wrote: Hi all I need to get the source ip from a udp header I read udp data in the following way.
Stephen Lintott wrote: recv = newsock.ReceiveFrom(data, ref tmpRemote);
I believe the source ip is staring you in the face (if not, hint: look at tmpRemote after the call).
|
|
|
|
|
First I thought that that was it but running the program I get our Gateway address instead of the router address. Why is this?
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
That sounds normal if the packet originated outside the local network. It is the normal behaviour of NAT I believe. If you are doing multicast, it wont even go beyond the local network, that's how UDP multicast work.
|
|
|
|
|
Thanks I was unsure about this.
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Hi All,
There is 2 comboboxes named "cmbMinNoSem", "cmbMinNoSem" and an Xml (that fetches the values from database). I want to get selected the combobox value that is in the xml. I have written the code as below:
cmbMinNoofSem.SelectedValue = xmlDom.GetElementsByTagName("min_no_of_semesters")[0].InnerText;
cmbMaxNoofSem.SelectedValue = xmlDom.GetElementsByTagName("max_no_of_semesters")[0].InnerText;
The first statement works fine but the second one does'nt
Thanks in advance.
Regards,
chanzeb chaudhary
|
|
|
|
|
Anyone know how you can get the current refresh rate of one (or more) monitors attatched to a computer? I can't seem to find it.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Start with the Win32 API GetDeviceCaps(), look for VREFRESH.
That's how we did it in the old days, anyway. This model may have changed with XP and Vista.
I would start by googling GetDeviceCaps, at any rate.
|
|
|
|
|
|
A more modern way would be to use WMI to get the device capabilities of attached hardware.
There, I've given you three starting points . Sorry I don't have code on hand for this.
Your new favorite word is "imbroglio".
|
|
|
|
|
|
Thanks. Slow day is it?
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
is there a way to get all the root paths of all the drives? like c:\ d:\ e:\ f:\ and so on..
|
|
|
|
|
WMI may help, but i dont know excatly how to do it. and there is probably a faster way, one of the guys here was using it to get the space used and space available on each drive on a system and remote server and it was kinda slow.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
string[] drives = Environment.GetLogicalDrives();
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|