I have an unmanaged C++ dll which is an MFC shared DLL that has functions in it to initialize sockets and do other ethernet related things. I have built a managed C++ wrapper project which is also an MFC shared DLL, compiled with /clr that calls functions in the unmanaged dll. Then I have a C# project which instantiates a member of the wrapper class to access the unmanaged functions.
One of the functions in the unmanaged dll creates a new CAsyncSocket, checks to see if AfxSocketInit is successful, and if so, calls Create to create a new socket. When I call this function through my wrapper from C#, I get a debug assertion when Create is called. The call stack trace indicates that the problem is in a call to AfxGetInstanceHandle.
I've done a lot of reading about the use of AfxGetInstanceHandle, but I can still not find any solution to this problem.
If anyone can help me out, I'd really appreciate it.
I am currently working on Serial Interface between a control box and PC and want to send/receive double values from Pc to the box as 8 uint8 values since the box only accepts in uint8 form.
For that i thought as follows : to get that double value (64 bits) in binary form and get the last 8 bits with &(and) operator and shifting bits to right till all bits are finished,namely :
char var2send; % in array
var2send= var & 0x00000000000000ff % last 8 bits with & operator
var>>8; %shifting bits
var2send= var & 0x00000000000000ff
. % and sending this array as output
But in this code, i received an error that says i cant use double with & operators so that must be converted 64 bit long form!! How can i manage to do this?? or anyone has better way or suggestion?
Thanks for your reply. The truth is that my drawing function is a lot more complicated than the example i showed in my message. I am going through three "for" loops to display 3D dispersions on a map.
I chose to use a pictureBox because i thought it would be easier to handle the map displaying (zooming in/out, panning etc) by specifying it as the pictureBox->image, and then drawing the rest on top and following the same zooming, panning etc. Not sure it is the best way to go about it, just chose it.
To cut a long story short, apart from removing the flickering from my drawing i wanted to use double buffering to also improve the speed of my displays because these are displayed in real time (would like to anyway every 10 seconds). I did manage to implement the GDI+ double buffering i was straggling with (amazingly enough i was drawing in "bmpBuf" and was displaying "bmpBufr" >:E). However, although the flickering went away the displaying speed did not improve enough.
Do you think the .NET way of handling double buffering would do better (i read that the .NET way is more optimized http://www.windowsforms.net/articles/windowsformspainting.aspx). Any help how do make this work? This is what i tried
I have been unable to receive a Byte in MC++. Whats the right syntax
this is the C# dll method.
public byte GetPictureBytes(Image _Pic)
byte _rtval = null;
MemoryStream mstr = new MemoryStream();
_rtval = mstr.GetBuffer();
Now i have to call this C# dll method in VC++.NET 2005
the syntax that i m using to call and receive this byte array is as follows but its creating some error.
array<byte^>^ myImage = gcnew array<byte^>^(1);
myImage = dllobj->GetPictureBytes(_myImage);
"array<byte^>^ myImage = gcnew array<byte^>^(1);
myImage = dllobj->GetPictureBytes(_myImage);"
// dllobj is of C# dll Class type that contains metod GetPictureBytes(Image _Pic);
// _myImage is Image type
i have used some other combinations also to receive the Byte array but cant having some errors. Plz guide me writing correct syntax to receive this Byte array in VC++.Net
THNX in Advance
I am currently trying to write a program that would detect if the colour red.
Basically i need to be able to set it up to monitor a certain portion of my screen (ie, bottom left, box shape) and when it detect a certian chape of red, it will return 1 or 0, or any type of return.
If this is to complicated to explain or to logn to quickly write a short code for it, i understand and thank you for your time in reading this post.
I want to register a sample fax routing dll on Windows XP,
I have found this sample DLL from Windows SDK.
I can not register it, while on Windows 2000 it can be registerered.
On Windows XP the error message is:
"The modem did not accept the command sent to it. verify the configured modem
matches the attached modem."
Anyone could help me plase?
Each time when I plug in USB memory stick to the pc, there is a window pops out. I have application to indicate whether a USB memory stick presents.I don't want this auto window to pop out. How shall I resolve it??