|
Hi David,
I think that what I posted was correct. I want to check if a user has "installed" a screen saver so that I can expect that there is a change that it will start running somewhen. Anyway, I check if it is actually running, too.
The howto on Q168877 seems to be exactly what I was looking for, great!
Thank you,
Marcus.
|
|
|
|
|
Hi,
I am creating an array of pointers that point to unsigned char arrays like so
unsigned char* data[3];
where
data[0] = new unsigned char[256];
data[1] = new unsigned char[256];
data[2] = new unsigned char[256];
I now want to return this pointer array data from one function. How can I do that? Or what way could I return data[0], data[1] and data[2]?
Thanks for any help cause am a bit stuck here
|
|
|
|
|
You can't return an array - If you burry it in a stuct you can work around this. i.e.
struct MyData
{
unsigned char* data[3];
};
MyData Function()
{
MyData md;
return md;
}
Steve
|
|
|
|
|
Oh ok! Thanks.
I will call that function in a different class though. So do I have to define another struct (lets call it MyData') and then lets say
void callFunction
{
md'.data[3]=Class::Function;
...}
How would I go about getting data[0], data[1] and data[2] then? Sorry just a bit confused as its like arrays, pointers and structs and am quite new to this.
Thanks in advance for any help!
|
|
|
|
|
Code like this:
MyData d1, d2;
d1 = d2;
Copies dt.data[0] , dt.data[1] and dt.data[2] (and all the rest if any).
Steve
|
|
|
|
|
you'll have to create the MyData::operator = () member for this, otherwise, it will only copy the addresses, not the array contents...
|
|
|
|
|
The question said, "return this pointer array" - I believe it's the addresses that he wants copied - Although it wasn't clearly stated.
Steve
|
|
|
|
|
Stephen Hewitt wrote: Although it wasn't clearly stated
agreed
|
|
|
|
|
your code is incorrect because you return a local object...
>> You can't return an array
yes we can, by returning the pointer... it is exactly the same when you pass arrays as parameters to functions.
|
|
|
|
|
v2.0 wrote: your code is incorrect because you return a local object...
No I don't - I return a copy of a local object - This is fine. Returning a pointer or reference to a local object is where you get into trouble.
v2.0 wrote: >> You can't return an array
yes we can, by returning the pointer... it is exactly the same when you pass arrays as parameters to functions.
Returning a pointer is not the same as returning an array - A process called "decay" occurs and you lose the size info. With the code I gave (array in a struct) an array is returned and no decay occurs and the length is not lost - But the data is copied not referenced.
Steve
|
|
|
|
|
Stephen Hewitt wrote: A process called "decay" occurs and you lose the size info
Not just that, but you also effectively change the type of the variable - an array is generally a valid location in memory (whose location cannot be changed easily), while a pointer can point to a valid location in memory. (This difference is also important when optimizing code.)
Peave!
-=- James 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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Since you have to put the returned array in an array anyway, you can create this "reception" array before calling the function and pass it as a parameter to the function. I think this is a much better solution than trying to "return" it, even burried in a struct.
~RaGE();
|
|
|
|
|
ahhhh, good ol' C runtime
Well done Mr "Diplomacy" ;P
|
|
|
|
|
V2.0 is too much for me. I'll go back to V1.6.
~RaGE();
|
|
|
|
|
v3.0 release date is set to 02/05/06... don't forget it
|
|
|
|
|
Hi i am doing a project and am making a tetris game in C++ V 6.0. So far i have crated the main menu screen... now i need to draw out a grid and start to make shapes fall... it seems i dont know how to do this. Does anyone have any tips or any codes i could have a look at??
Cheers for the help guys!
|
|
|
|
|
The best option is probably to create a custom control and do all the drawing yourself. Take a look at the miscellaneous controls on this site to see how to make one (it is not easy). Then to make the shapes fall, I think a timer will do that.
|
|
|
|
|
Hi!
Another way how to find out how to do that is to have a look at some related articles here on codeproject. Just type "tetris" to the search bar and you will get some hits, e.g.:
http://www.codeproject.com/cpp/CImgTetris.asp[^]
Best regards,
Marcus.
|
|
|
|
|
To start without debug is OK, but when I press F5 to start debugging, then it tells me that:
Debugging information for "....exe" cannot be found or does not match.
Binary was not built with debug information.
The "Solution Configurations" has already be set as "Debug".
Why cannot start debugging?
The problem only exists in C++, while C# is OK.
I've installed fully except x64 choice in C++.
VS2005 team suite edition.
华夏光宇世界,文明引领着我纵横驰骋于天地之间。
|
|
|
|
|
Open the project propertiesm choose 'General' under the 'C/C++' item. There you should see "Debug information Format". Make sure "Program Database" at least is selected.
Hope this helps
|
|
|
|
|
Thank you but the problem still stay there.
Having altered the "Debug Information Format" to "Programme Database", press F5.......
The Output Window tells me that:
"
'HuffmanTree.exe': Loaded 'C:\Documents and Settings\libo\My Documents\Visual Studio 2005\Projects\HuffmanTree\debug\HuffmanTree.exe', Binary was not built with debug information.
'HuffmanTree.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'HuffmanTree.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
The program '[5592] HuffmanTree.exe: Native' has exited with code 0 (0x0).
"
You see. I am coding the programme called "HuffmanTree", and to start without debug is OK.
华夏光宇世界,文明引领着我纵横驰骋于天地之间。
|
|
|
|
|
Dear All,
I am using the following code to get the printer status.
BOOL bSuccess = FALSE;
char *pPrinterName = NULL;
DWORD size = 0;
GetDefaultPrinter(pPrinterName, &size);
pPrinterName = new char[size+1];
memset(pPrinterName,'\0',size+1);
if(GetDefaultPrinter(pPrinterName, &size) == FALSE)
{
delete[]pPrinterName;
return ;
}
PRINTER_DEFAULTS* pd=NULL;
BOOL bOpen = OpenPrinter(pPrinterName, &hPrinter, pd);
if(!bOpen)
{
delete[]pPrinterName;
return;
}
delete [] pPrinterName;
GetPrinter(hPrinter, 2, NULL, 0, &dwBytesNeeded);
BOOL bSuccess = FALSE;
PRINTER_INFO_2 *pPrinterInfo;
pPrinterInfo=(PRINTER_INFO_2*)GlobalAlloc(GPTR,dwBytesNeeded);
bSuccess = GetPrinter(hPrinter, 2, (LPBYTE)pPrinterInfo, dwBytesNeeded,&dwBytesReturned);
if(bSuccess == FALSE)
return FALSE;
bSuccess=TRUE;
if(pPrinterInfo->Status != 0)
{
if((pPrinterInfo->Status)&PRINTER_STATUS_BUSY)
{
ShowMessage("Printer is busy");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_DOOR_OPEN)
{
ShowMessage("Printer door is open");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_ERROR)
{
ShowMessage("Printer is in error state");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_INITIALIZING)
{
ShowMessage("Printer is initializing");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_IO_ACTIVE)
{
ShowMessage("Printer is in an active state");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_MANUAL_FEED)
{
ShowMessage("Printer is in a manual feed state");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_NO_TONER)
{
ShowMessage("Printer is out of toner");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_NOT_AVAILABLE)
{
ShowMessage("Printer not present");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_OFFLINE)
{
ShowMessage("Printer is offline");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_OUT_OF_MEMORY)
{
ShowMessage("Printer is out of memory");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_OUTPUT_BIN_FULL)
{
ShowMessage("Printer's output bin is full");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_PAGE_PUNT)
{
ShowMessage("Page punt error");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_PAPER_JAM)
{
ShowMessage("Paper is jammed in the printer");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_PAPER_OUT)
{
ShowMessage("Printer is out of paper");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_PAPER_PROBLEM)
{
ShowMessage("Printer has a paper problem");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_PAUSED)
{
ShowMessage("Printer is paused");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_PENDING_DELETION)
{
ShowMessage("Printer is deleting a print job");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_POWER_SAVE)
{
ShowMessage("Printer is in power save mode");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_PRINTING)
{
ShowMessage("Printer is printing");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_PROCESSING)
{
ShowMessage("Printer is processing a print job");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_SERVER_UNKNOWN)
{
ShowMessage("Printer status is unknown");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_TONER_LOW)
{
ShowMessage("Printer is low on toner");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_USER_INTERVENTION)
{
ShowMessage("Printer has an error that requires the user to do something");
bSuccess = FALSE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_WAITING)
{
ShowMessage("Printer is waiting");
bSuccess = TRUE;
}
if((pPrinterInfo->Status)&PRINTER_STATUS_WARMING_UP)
{
ShowMessage("Printer is warming up");
bSuccess = TRUE;
}
}
GlobalFree(pPrinterInfo);
The "pPrinterInfo->Status" parameter always returns "0" for the local
USB printer.Can anyone please tell me what may be the problem.
Thanking you in advance,
regards,
Ashwath Hegde.
|
|
|
|
|
0 might be a valid return for "normal/online/ready" status. You can check by intentionally "breaking" the printer by taking it offline, removing paper from it, opening it up, etc., and see if the status value changes accordingly.
Peace!
-=- James 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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
hi,
I have checked all those conditions but it does not work.I am using Windows XP machine.Should i install any service pack for this.
|
|
|
|
|
I ran into similar issues with a serial port printer and one connected to the parallel port. It turns out all 'suggestions' I discovered at Microsoft or on the Internet pointed to writing a 'printer monitor' type of driver. The notion was that the actual 'status' did not 'percolate' all the way up to this function call which should OBVIOUSLY be receiving the status. So, what I am trying to say is that I don't think your problem is specific only to the USB printer.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|