|
Move the extern "C" outside of the class so that it encompasses the entire class.
extern "C"
{
class Vdr
{
public:
__declspec (dllexport)
int add (int a, int b);
};
}
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks for the suggestion, but unfortunately it still appears to be generating decorated method names.
|
|
|
|
|
OK - but it does not make sense for the method names to be exported in C format, because (member) methods are specific to C++.
Perhaps you want to export simple functions (no references!) and have them in undecorated names?
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
That's what I decided to do; according to Nemanja (above) extern "C" cannot be applied to members of a class; just functions.
=================
BTW, in case anyone's interested, I just figured out how to pass objects from C# to C++:
BitmapInfo bi = new BitmapInfo ();
IntPtr ptr = (IntPtr) (&bi);
CppFunction (ptr);
|
|
|
|
|
You can lead a horse to water but you can't make him fish
led mike
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Alan Balkany wrote: I'm trying to make a C++ DLL with non-decorated method names that can be called from .NET.
Are you trying to use a native C++ class from .NET? Can't do that. Either make a COM wrapper, a C++/CLI one, or export the functionality from the DLL with plain C functions.
The specifier extern "C" can be used only on non-member functions, and besides the exported functions will still be decorated, although in a different way.
|
|
|
|
|
Ah, so what I was trying is impossible. Thanks.
Apparently static methods can be used from .NET, although they're decorated. I think I'll take your suggestion and use C functions.
|
|
|
|
|
i want to read a file and input each record by record into shared memory .
|
|
|
|
|
Nice intention, get to work!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Your question relates to what ? using fgets or using shared memory ?
|
|
|
|
|
yes,i want to put the data to shared memory and by using another process need to read them
|
|
|
|
|
I am trying to enumarate an USB device. This is a regular flash drive. I am using this piece of code
int main(void)
{
GUID USBIODS_GUID;
USBIODS_GUID.Data1 = 0x4D36E967;
USBIODS_GUID.Data2 = 0xE325;
USBIODS_GUID.Data3 = 0x11CE;
USBIODS_GUID.Data4[0] = 0xBF;
USBIODS_GUID.Data4[1] = 0xC1;
USBIODS_GUID.Data4[2] = 0x08;
USBIODS_GUID.Data4[3] = 0x0;
USBIODS_GUID.Data4[4] = 0x2B;
USBIODS_GUID.Data4[5] = 0xE1;
USBIODS_GUID.Data4[6] = 0x03;
USBIODS_GUID.Data4[7] = 0x18;
HDEVINFO hInfo = SetupDiGetClassDevs(&USBIODS_GUID, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
for (DWORD i=0; ; ++i)
{
SP_INTERFACE_DEVICE_DATA Interface_Info;
Interface_Info.cbSize = sizeof(Interface_Info);
Enumerate device
if (!SetupDiEnumDeviceInterfaces(hInfo, NULL, (LPGUID) &USBIODS_GUID,i, &Interface_Info))
{
int err = GetLastError();
SetupDiDestroyDeviceInfoList(hInfo);
return(i);
}
}
}
I obtained the UID for this device from the registry.
The SetupDiEnumDeviceInterfaces returns ERROR_NO_MORE_ITEMS
Where have I gone wrong?
Also what is the difference between functions SetupDiEnumDeviceInterfaces () and SetupDiEnumInterfaceDevice()
|
|
|
|
|
koumodaki wrote: The SetupDiEnumDeviceInterfaces returns ERROR_NO_MORE_ITEMS
Where have I gone wrong?
By possibly not reading the documentation:
MemberIndex - Specifies a zero-based index into the list of interfaces in the device information set. The caller should call this function first with MemberIndex set to zero to obtain the first interface. Then, repeatedly increment MemberIndex and retrieve an interface until this function fails and GetLastError returns ERROR_NO_MORE_ITEMS.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It is set to 0. I am passing a variable i as a parameter which I have initilized to zero in the for loop
|
|
|
|
|
Did you not read that last sentence?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I saw it and made the chages too. Still I am facting the same problem.
|
|
|
|
|
koumodaki wrote: I saw it and made the chages too. Still I am facting the same problem.
So are we going to see the changed code?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Sorry. I actually modified the code to see if I can atleast get the 1st interface.
int main(void)
{
GUID USBIODS_GUID;
USBIODS_GUID.Data1 = 0x4D36E967;
USBIODS_GUID.Data2 = 0xE325;
USBIODS_GUID.Data3 = 0x11CE;
USBIODS_GUID.Data4[0] = 0xBF;
USBIODS_GUID.Data4[1] = 0xC1;
USBIODS_GUID.Data4[2] = 0x08;
USBIODS_GUID.Data4[3] = 0x0;
USBIODS_GUID.Data4[4] = 0x2B;
USBIODS_GUID.Data4[5] = 0xE1;
USBIODS_GUID.Data4[6] = 0x03;
USBIODS_GUID.Data4[7] = 0x18;
HDEVINFO hInfo = SetupDiGetClassDevs(&USBIODS_GUID, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
if (hInfo == INVALID_HANDLE_VALUE)
{
return 1;
}
SP_DEVINFO_DATA DeviceInfoData;
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
SP_INTERFACE_DEVICE_DATA Interface_Info;
Interface_Info.cbSize = sizeof(Interface_Info);
if(!SetupDiEnumDeviceInterfaces(hInfo, &DeviceInfoData, (LPGUID) &USBIODS_GUID,0, &Interface_Info))
{
int err = GetLastError();
SetupDiDestroyDeviceInfoList(hInfo);
return(0);
}
}
The function fails even now.
|
|
|
|
|
Your code snippet worked fine for me. With only one item to enumerate, SetupDiEnumDeviceInterfaces() returned 0 and GetLastError() returned ERROR_NO_MORE_ITEMS as expected.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Oh, I thought the function should return 1 because it was successful in getting the interface. Am I missing something here? Does it mean that I am able to get the interface of the device who’s GUID I have assigned to USBIODS_GUID variable passing as parameter to the function?
Could you please explain to me, Mr Crow?
|
|
|
|
|
koumodaki wrote: Am I missing something here?
Yes. It will return nonzero if it completed without error, or it will return 0 if there are no more items (i.e., GetLastError() returns ERROR_NO_MORE_ITEMS ).
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
this is what I do:
HBITMAP hbm;
hbm = (HBITMAP)LoadImage(NULL, L"./image1.bmp", IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
This works on .bmp files. But I wish to load .png files.
|
|
|
|
|
Have you considered using CImage ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm trying to use DirectDraw inteface.
CImage is considerable. I tried to use it and got messed in the HDC stuff.
|
|
|
|