|
|
It's the result of a Google search which may help in your researches.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I want to use many a rc file in vc6 project when compiling, dsp file format is below:
# Begin Source File
SOURCE=.\05.rc -> corresponding to r5.h
# End Source File
# Begin Source File
SOURCE=.\04.rc -> corresponding to r4.h
# End Source File
# Begin Source File
SOURCE=.\03.rc -> corresponding to r3.h
# End Source File
# Begin Source File
SOURCE=.\r5.h
# End Source File
# Begin Source File
SOURCE=.\r4.h
# End Source File
# Begin Source File
SOURCE=.\r3.h
# End Source File
there is a link error(cannot open file ".\Debug\05.res") when compiling,
03.res is created, 04.res and 05.res are not created,how can I do ?
modified 28-Nov-12 2:17am.
|
|
|
|
|
Do not do this by editing the .dsp file. Use the Solution window of the IDE to add files to your project.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
when Adding another rc file to workspace, IDE prompt only one resource file can be added to project when compiling。
|
|
|
|
|
yingkou wrote: I want to use many a rc file in vc6 project when compiling, dsp file format is below: You can have only one .rc file, but I believe you can have multiple .rc2 files.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
You can open the primary .rc file in text mode and include the other .rc files. We do this for translation purposes in one of our applications.
|
|
|
|
|
Hello Friends
I ported my application from VC6 to VS2010 in mfc.In vc6 , using 8bit indexed bmp as Dialog'Toolbar. But in VS2010,after porting Icons colors are corrupted and not showing icons properly.And Icons which are disabled are hidden. Its showing up only when they get enabled.
So,now m facing two problems:
first,Icons colors are not proper.
Second,its showing background color too. m Guessing that background color only hiding my icons on disable.Its not showing transparency as it is happening with 8bit images.Any Ideas?
I tried by changing bmp to 32 bit then icon'color came fine but other prob still.
Any help will be Appreciated.
Thanks & Regards
Yogesh
|
|
|
|
|
|
Thanks Hadi.
Icons are coming fine now after changing them to 32 bit and On Disable they stay there bcoz it has transparency channel in it.
But this Doesnt solve my problem completely.
What happeniing is now that When I am disabling any Toolbar Icon,It looks like colored and dim as compared to total gray in VC6.
Any Ideas?
Thanks
Yogesh
|
|
|
|
|
You're welcome
You must use the tool(Pixelformer) and edit your bitmap.
It supports 32 bit and trancparency.
I've tested it and I'm sure it works.
www.logicsims.ir
|
|
|
|
|
I want to use macro in .dsp file for load different file to workspace,just as below:
123 is a sub-folder of 04 project folder and there is a 04.rc and resource.h
!IF "$(CFG)" == "04 - Win32 Release"
RCF=..\\123\\04.rc
RCH=..\\123\\Resource.h
!ELSEIF "$(CFG)" == "04 - Win32 Debug"
RCF=..\\123\\04.rc
RCH=..\\123\\Resource.h
!ENDIF
# Begin Target
...
# Begin Source File
SOURCE=RCF
# End Source File
Begin Source File
SOURCE=RCH
# End Source File
# End Target
Open workspace by VC6 IDE, RC is not loaded and RCF and RCF are display as a file name in workspace but empty,why?how should I do for doing this work well。
Change macro definition as below,result is same
RCF=.\123\04.rc
RCH=.\123\Resource.h
|
|
|
|
|
What are you trying to achieve by doing this? ...I don't remember having to edit this file directly ever, you should be able to make any changes regarding project files and compilation changes from the IDE.
|
|
|
|
|
different mode needs different rc file
|
|
|
|
|
I can see that... but why do you need a different resource for debug and release?
|
|
|
|
|
Hi. Help me, please! Why this class doesn't work for Subtraction, Division and Square Root. When I try to get results for Subtraction, it output right answer, but with any trash. And When I try to get answer for Division and Square Root, it just brakes and don't output anything. For Addition and Multiplication class work correctly. Thank U very mush, if you will help me.
Its the link to this class
http://www.codeproject.com/Articles/1202/A-class-for-operations-with-Large-Integer-Numbers
|
|
|
|
|
Typically for questions regarding a specific article, you'd want to ask those in the specific article page (see the large "Add Comment or Question" button in the bottom of the article?). Also, your question isn't all that clear, so see if you can rephrase and make it more clear.
|
|
|
|
|
As Albert said, the best place to ask such a question is as a comment to the article.
Anyway, it's impossible to offer any help if you don't at least provide the code that does not work. That means your code.
By the way you should really read and follow the instructions given in "How to ask a question" which you can find at the top of this forum. That will greatly increase your chances of getting a relevant answer.
|
|
|
|
|
SetupDiGetDeviceRegistryProperty API suppose returns required buffer size for "Property" beeing inquired about.
It does but it also returns variety of errors.
( invalid data, data "too short" - whatever that means )
The function never returns true when with parameters are set to return buffer size.
Is that normal?
For example if I inqiure about SPDRP_FRIENDLYNAME the buffer size returned is 0.
Here is my code, keep in mind it is a test code!
I have aslo included partial MS function desription.
Many thanks for your help.
Cheers Vaclav
DWORD DataT;
LPTSTR buffer = NULL;
DWORD buffersize = 0; // 2048; // 0;
int iCounter = 0;
buffer = (LPTSTR)LocalAlloc(LPTR, buffersize * 2);
TRACE("\nSetupDiGetDeviceRegistryProperty...");
TRACE("\nReturn required buffer size only ");
Property = SPDRP_FRIENDLYNAME; // SPDRP_DEVTYPE; // SPDRP_COMPATIBLEIDS; // SPDRP_CLASS;
do
{
bool bResult = false;
do
{
bResult = SetupDiGetDeviceRegistryProperty(
hDevInfo, // _In_ HDEVINFO DeviceInfoSet,
&DeviceInfoData, // _In_ PSP_DEVINFO_DATA DeviceInfoData
Property, // _In_ DWORD Property,
&DataT, // _Out_opt_ PDWORD PropertyRegDataType,
NULL, // get size with NULL (PBYTE)buffer, // _Out_opt_ PBYTE PropertyBuffer,
0, // get size with 0 buffersize,
&buffersize); // fills buffer size
if(buffersize)
{
TRACE("\n");
bResult = SetupDiGetDeviceRegistryProperty(
hDevInfo, // _In_ HDEVINFO DeviceInfoSet,
&DeviceInfoData, // _In_ PSP_DEVINFO_DATA DeviceInfoData
Property, // _In_ DWORD Property,
&DataT, // _Out_opt_ PDWORD PropertyRegDataType,
(PBYTE)buffer, // _Out_opt_ PBYTE PropertyBuffer,
buffersize,
&buffersize); // fills buffer size
}
TRACE("\nProperty %i ",Property);
Property++;
TRACE("\nProperty %i ",Property);
}
while (!bResult & Property <= SPDRP_UPPERFILTERS);
PropertyBuffer [out, optional]
A pointer to a buffer that receives the property that is being retrieved. If this parameter is set to NULL, and PropertyBufferSize is also set to zero, the function returns the required size for the buffer in RequiredSize.
PropertyBufferSize [in]
The size, in bytes, of the PropertyBuffer buffer.
RequiredSize [out, optional]
A pointer to a variable of type DWORD that receives the required size, in bytes, of the PropertyBuffer buffer that is required to hold the data for the requested property. This parameter is optional and can be NULL.
Return value
SetupDiGetDeviceRegistryProperty returns TRUE if the call was successful. Otherwise, it returns FALSE and the logged error can be retrieved by making a call to GetLastError. SetupDiGetDeviceRegistryProperty returns the ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is not valid.
|
|
|
|
|
What are the values of your input parameters, they are not shown above? Please also use <pre> tags round your code so it is more readable.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I've just tested it and got also FALSE returned when requesting the size. The returned error is 122 / ERROR_INSUFFICIENT_BUFFER . So it seems that this is intentional.
But you must check the error code (e.g. when passing NULL for PropertyBuffer and a value greater NULL for PropertyBufferSize , code 87 / ERROR_INVALID_PARAMETER is set and the returned size is set to the passed value).
If you got other errors like ERROR_INVALID_DATA , check your parameters. Note that the size member of the DeviceInfoData parameter must be initialized:
SP_DEVINFO_DATA DevInfoData;
::ZeroMemory(&DevInfoData, sizeof(SP_DEVINFO_DATA));
DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
|
|
|
|
Here is some of the "calling code", still in test development.( I know it is a mess. sorry)
If I just use this property DWORD Property = SPDRP_DEVICEDESC;
I still get error when looking for the buffewr size only,
but get the size OK.
Than I get another error - something "the parameter passed to the system is too small". I am trying to find some explanation for this error just for the SetupDiGetDeviceRegistryProperty.There are tons of posts about this error , but nothing specific for this function I found so far.
What bugs me is that ewerybody is copying the original MS device iteration sample code and set the buffer to value and when it fails ( allegedly for Win2000 only ) they increase it. That tells me that the setting for finding the buffer size may not really work, hence all these errors.
Thanks for all you help, appreciate it.
bool C_USB::C_Enumerate_All()
{
TRACE("\nbool C_USB::C_Enumerate_All()");
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
CString strLabel = "Friendly name ";
DWORD i;
TRACE("\nCreate a HDEVINFO with all present devices");
TRACE("\nSetupDiGetClassDevs... Create a HDEVINFO with all present devices");
hDevInfo = SetupDiGetClassDevs(
NULL,
0, // Enumerator
0,
DIGCF_PRESENT | DIGCF_ALLCLASSES);
if (INVALID_HANDLE_VALUE == hDevInfo)
{
TRACE("\nINVALID_HANDLE_VALUE == hDevInfo");
// Insert error handling here.
return 1;
}
// Enumerate through all devices in Set.
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
TRACE("\nSetupDiEnumDeviceInfo...Enumerate through all devices in Set");
/*
DeviceInfoSet [in]
A handle to the device information set for which to return an SP_DEVINFO_DATA
structure that represents a device information element.
MemberIndex [in]
A zero-based index of the device information element to retrieve.
DeviceInfoData [out]
A pointer to an SP_DEVINFO_DATA structure to receive information about
an enumerated device information element. The caller must
set DeviceInfoData.cbSize to sizeof(SP_DEVINFO_DATA).
*/
for (i = 0; SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData); i++)
{
//LPTSTR buffer = NULL;
//DWORD buffersize = 0;
//TRACE("\nShow property using friendly name flag");
TRACE("\nTest show device description ");
DWORD Property = SPDRP_DEVICEDESC;
C_TestPrintProperty(
hDevInfo,
DeviceInfoData,
strLabel,
Property);
/* enumerate all properties test
do
{
C_TestPrintProperty(
hDevInfo,
DeviceInfoData,
strLabel,
Property);
// Property++;
TRACE("\nEnumerate property counter %i", Property);
}while (Property++ != SPDRP_MAXIMUM_PROPERTY);
*/
TRACE("\nEnumerate progress counter %i", i);
}
void C_USB::C_TestPrintProperty(
HDEVINFO hDevInfo,
SP_DEVINFO_DATA DeviceInfoData,
CString strLabel,
DWORD Property)
{
TRACE("\n void C_USB::C_TestPrintProperty(CString strLabel)");
DWORD DataT;
LPTSTR buffer = NULL;
DWORD buffersize = 2048; // 0;
int iCounter = 0;
bool bResult = false;
//buffer = (LPTSTR)LocalAlloc(LPTR, buffersize * 2);
TRACE("\nSetupDiGetDeviceRegistryProperty...");
TRACE("\nReturn required buffer size only ");
// Property = 0; //SPDRP_FRIENDLYNAME; // SPDRP_DEVTYPE; // SPDRP_COMPATIBLEIDS; // SPDRP_CLASS;
bResult = SetupDiGetDeviceRegistryProperty(
hDevInfo, // _In_ HDEVINFO DeviceInfoSet,
&DeviceInfoData, // _In_ PSP_DEVINFO_DATA DeviceInfoData
Property, // _In_ DWORD Property,
&DataT, // _Out_opt_ PDWORD PropertyRegDataType,
NULL, // get size with NULL (PBYTE)buffer, // _Out_opt_ PBYTE PropertyBuffer,
0, // get size with 0 buffersize,
&buffersize); // fills buffer size
// check result
if(!bResult)
{
TRACE("\nMFC Error dialog ");
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
MessageBox( (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
goto TEMP;
}
if(buffersize)
{
TRACE("\nFill buffer with property data ");
bResult = SetupDiGetDeviceRegistryProperty(
hDevInfo, // _In_ HDEVINFO DeviceInfoSet,
&DeviceInfoData, // _In_ PSP_DEVINFO_DATA DeviceInfoData
Property, // _In_ DWORD Property,
&DataT, // _Out_opt_ PDWORD PropertyRegDataType,
(PBYTE)buffer, // _Out_opt_ PBYTE PropertyBuffer,
buffersize,
&buffersize); // fills buffer size
// check result
if(!bResult)
{
TRACE("\nMFC Error dialog ");
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
MessageBox( (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
}
}
TEMP:
TRACE("\nBuffer %s ",buffer);
TRACE("\nProperty %i ",Property);
return;
|
|
|
|
|
I did not look up all the code (hint: format it as code to improve readability). But I recognized that you print the error message using FormatMessage() . SetupAPI messages are a little bit special. To get the correct error message you must use the macro HRESULT_FROM_SETUPAPI() to pass error codes to FormatMessage() .
See the Guidelines for Using SetupAPI[^]. It also mentions that querying buffer sizes fails with ERROR_INSUFFICIENT_BUFFER (I did not remember when answering first).
|
|
|
|
|
Here is another try.
It is true that the sizing of the buffer will fail as poited out in the sample code which I copied / modified.
I have no problem getting readable messages using MFC code, but I made a mistake asking for the error message twice. Also got sidetracked by the error - I guess I was looking for something about buffer size.
All this aside - when I ask for buffer using SPDRP_DEVICEDESC it sort-off works,
but I did not looked up what exactly SPDRP_DEVICEDESC should contain. I am interested in friendly name for now.
But when I use SPDRP_FRIENDLYNAME , the sizing of buffer fails with "Data is invalid" and the buffer is still 0;
PS I copy my code into here with "code" selected and do preview and it looks formated to me. I have no clue if you guys do not see same format as me. SOrry.
// display list of all (installed) hardware devices
bool C_USB::C_DeviceList()
{
TRACE("\nbool C_USB::C_DeviceList()");
TRACE("\ndisplay list of all (installed) hardware devices");
TRACE("\nEnumerator test ");
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
DWORD i;
HDEVINFO DeviceInfoSet = SetupDiGetClassDevs(
NULL,
"USB", //NULL,
NULL,
DIGCF_ALLCLASSES | DIGCF_PRESENT);
TRACE("\nSetupDiGetClassDevs.. USB devices ");
// Create a HDEVINFO with all present devices.
hDevInfo = SetupDiGetClassDevs(NULL,
0, // Enumerator
0,
DIGCF_PRESENT | DIGCF_ALLCLASSES );
if (hDevInfo == INVALID_HANDLE_VALUE)
{
// Insert error handling here.
return 1;
}
// Enumerate through all devices in Set.
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i=0;SetupDiEnumDeviceInfo(hDevInfo,i,
&DeviceInfoData);i++)
{
DWORD DataT;
LPTSTR buffer = NULL;
DWORD buffersize = 0;
DWORD Property = SPDRP_FRIENDLYNAME;
// SPDRP_DEVICEDESC;SPDRP_FRIENDLYNAME
// retrieve a REG_SZ string that contains the friendly name of a device.
//
// Call function with null to begin with,
// then use the returned buffer size (doubled)
// to Alloc the buffer. Keep calling until
// success or an unknown failure.
//
// Double the returned buffersize to correct
// for underlying legacy CM functions that
// return an incorrect buffersize value on
// DBCS/MBCS systems.
//
while (!SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_DEVICEDESC, //Property,
&DataT,
(PBYTE)buffer,
buffersize,
&buffersize))
{
{
TRACE("\nMFC Error dialog ");
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
// The data area passed to a system call is too
// small.
MessageBox( (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
// Change the buffer size.
/*
if (buffer) LocalFree(buffer);
// Double the size to avoid problems on
// W2k MBCS systems per KB 888609.
buffer = LocalAlloc(LPTR,buffersize * 2);
*/
buffersize = buffersize*2;
// do it again with larger buffer
while (!SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
Property,
&DataT,
(PBYTE)buffer,
buffersize,
&buffersize))
{
{
TRACE("\nMFC Error dialog ");
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Process any inserts in lpMsgBuf.
// ...
// Display the string.
// The data area passed to a system call is too
// small.
MessageBox( (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
// Change the buffer size.
/*
if (buffer) LocalFree(buffer);
// Double the size to avoid problems on
// W2k MBCS systems per KB 888609.
buffer = LocalAlloc(LPTR,buffersize * 2);
*/
//buffersize = buffersize*2;
}
}
if (GetLastError() ==
ERROR_INSUFFICIENT_BUFFER)
{
// Change the buffer size.
if (buffer) LocalFree(buffer);
// Double the size to avoid problems on
// W2k MBCS systems per KB 888609.
// CCCC buffer = LocalAlloc(LPTR,buffersize * 2);
}
else
{
// Insert error handling here.
break;
}
}
printf("Result:[%s]\n",buffer);
if (buffer) LocalFree(buffer);
}
if ( GetLastError()!=NO_ERROR &&
GetLastError()!=ERROR_NO_MORE_ITEMS )
{
// Insert error handling here.
return 1;
}
// Cleanup
SetupDiDestroyDeviceInfoList(hDevInfo);
|
|
|
|
|
To get closer, try using a fixed buffer with size 1024 byte. This is sufficient for the requested information (resulting in max.length of 511 Unicode characters).
To format code, use the 'code' link just above the edit window. You can apply code formatting also to your existing posts:
- Choose the 'Edit' link below your post
- Select the text that should be formatted
- Move the mouse over the 'code' link and choose 'C++'
The result is a code block with fixed font and syntax coloring.
|
|
|
|
|