|
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.
|
|
|
|
|
Hanan888 wrote: I tried to use it and got messed in the HDC stuff.
May be if you could show us the mess, someone may help you clean it up.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Here is some mess:
First look then I'll detail:
CImage image
PAINTSTRUCT ps;
HDC hDC = BeginPaint (m_hWnd, &ps) ;
(line 4)
(line5) image.Load(L"./image.png");
image.Draw(hDC, (int) iter->second.m_pStaticData->m_UL.x, (int)
iter->second.m_pStaticData->m_UL.y);
EndPaint(m_hWnd, &ps);
This is 'below':
CImage image;
image.Load(L"./image.png");
pStatData->m_Texture = image;
The bottom line - no picture were painted. Painted all white.
(line 4) crashed.
(line 4) and (line 5) behave differently, can't understand why.
Perhaps there are some 'unwritten rules' for HDC stuff, I don't know them, I totally admit some sort of ignorance.
|
|
|
|
|
GDI has nothing to do with DirectDraw.
Check the return value from the CImage::Load() call....it's probably
failing since you're passing an invalid path.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hanan888 wrote: L"./image.png"
this should probably be _T(".\\image.png") .
forget it.
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
|
|
|
|
|
I seem to recall that string literals can use either single slashes or double backslashes. I've not bothered to confirm this, however.
"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 made a test, you're right.
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
|
|
|
|
|
Hello Friends!
I've found an article of Amit Dey for creating Office Addins.
I am using office2003 and VC 6.0. I've created an ATL dll by following
his steps.I've registered this DLL but I can't see this addin when I want
to add this addin in outlook.Can anyone figure out what could be the
problem?
Thanks in Advance.
ritz1234
|
|
|
|
|
Do you see the entry for the addin in the registry.
Is the addin enabled from under the Tools menu. It might be disabled.
Check for wither of these two problems and could be that you come out of it.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks for the greate response.
yes,the registry entry has been created.
Under Tools menu when I click COM-AddIns.. for adding this,
I see Addin-available dialogbox that is empty.I don't have anything to
select from here.
ritz1234
|
|
|
|