|
the printer is HP Photosmart C7100 series which is pointed to by pn
hdcPrinter is declared as HDC hdcprinter.
Copy & paste doesn't work in the compiler window I will try and type it.
In function 'BOOL SavePrintFile(HWND_*,HDC_)'.
invalid conversion from 'HDC_ **'to 'void**'
initilizing argument2 of 'BOOL OpenPrinterA(CHAR*,void**,_PRINTER_DEFAULTSA)'
[Build Error] [maingfa.o] Error 1
|
|
|
|
|
The OpenPrinter Function[^] expects the second argument to be a HANDLE not an HDC.
Here is an example of using OpenPrinter to open the default printer using the GetDefaultPrinter Function[^]
#include <Winspool.h>
HANDLE OpenDefaultPrinter(ACCESS_MASK dwMask)
{
HANDLE hPrinter = INVALID_HANDLE_VALUE;
PRINTER_DEFAULTS pDef = {0};
DWORD dwSize;
GetDefaultPrinter(NULL, &dwSize);
TCHAR* szBuffer = (TCHAR *)alloca(sizeof(TCHAR) * dwSize);
if(NULL != szBuffer)
{
if(GetDefaultPrinter(szBuffer, &dwSize))
{
pDef.DesiredAccess = dwMask;
OpenPrinter(szBuffer, &hPrinter, &pDef);
}
}
return hPrinter;
}
OpenDefaultPrinter(PRINTER_ALL_ACCESS);
Best Wishes,
-David Delaune
[UPDATE]
You should remove my call to alloca and use heap-based memory allocation with the new/delete operators. My personal projects usually have structured exception handler for stack overflows and I inadvertently used alloca in this comment.
modified on Tuesday, August 11, 2009 4:46 PM
|
|
|
|
|
Hi,
Below is the line of code(C++) for Reading the Textfile line by line.
CString = strFilePath; // text path file path
ifstream Textfile;
Textfile.open(strFilePath,ios::in);
std::string value;
while(!Textfile.eof())
{
getline(Textfile,value); // Read line by line...
}
Textfile.close();
Now the question is I am having 40MB text file size. I need to read 1000 Lines in a single shot (And upto read 1000 times to reach the whole 40 MB size) not line by line. How to do this?
(ie from 1 to 1000 and 1001 to 2000.... reach max lines)
reg,
Subbu
|
|
|
|
|
To read a line from a file, you effectively need to read the file character by character - that's how you find the line termninator character.
Sounds to me like you'd be better off memory mapping the whole file and processing it in memory
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
spalanivel wrote: How to do this?
You can't. You can, however, reduce file I/O by reading the entire file once into a buffer and then process that buffer instead. See Stuart's suggestion.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi
I want a free class or utility that can open a PDF file and sets its field's value(for use in a MFC app).
Any idea or suggestion or guide?
Thanks
www.logicsims.ir
|
|
|
|
|
You can give OpenPDF[^] a try.
1300 calories of pure beef goodness can't be wrong!
|
|
|
|
|
It's a java based application.
I want a utility not an application!
www.logicsims.ir
|
|
|
|
|
It's a java based application not a library!
I want a library to use it from my MFC program!
www.logicsims.ir
|
|
|
|
|
Hadi Dayvary wrote: I want a library to use it from my MFC program!
Take a look at DynaPDF[^] and PoDoFo[^]
1300 calories of pure beef goodness can't be wrong!
|
|
|
|
|
search google with this term "PDF writing library c++ "
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
int main() {
char * lpszData = "file=abcdefg&info=&x=3&4=5";
int count = 0;
char * pt = strchr(lpszData, '&');
while ( pt != NULL ) {
count++;
pt = strchr(++pt, '&');
};
cout << "Data: " << lpszData << "\n";
cout << "Count: " << count << "\n\n";
char ** split = new char * [count + 1];
char * start = lpszData;
for (int i = 0; i <= count; i++) {
pt = strchr(start, '&');
if ( pt == NULL )
pt = lpszData + strlen(lpszData);
split[i] = new char[pt - start + 1];
strset(split[i], 0);
strncpy(split[i], start, pt - start);
start = pt + 1;
};
for (int i = 0; i <= count; i++) {
cout << "split[" << i << "] = " << split[i] << "\n";
};
for (int i = 0; i <= count; i++)
delete [] split[i];
delete [] split;
} First, the delte [] split[i]; in the for loop at the end gives me an error, but when I remove this line the code leaks.
Second, the output is:
Data: file=abcdefg&info=&x=3&4=5
Count: 3
split[0] = file=abcdefg
split[1] = info=[extended_char]3
split[2] = x=3
split[3] = 4=5 Try as I might I can't figure out where the extra characters are coming from in split[1] .
Can anyone help with either of these problems?
Thanks for any assistance you can give,
MZR
|
|
|
|
|
Mike the Red wrote: strset(split[i], 0);
Replace with
split[i][pt - start]='\0';
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
[My articles]
|
|
|
|
|
|
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
[My articles]
|
|
|
|
|
Mike the Red wrote: split[i] = new char[pt - start + 1];
strset(split[i], 0);
The second statement is effectively canceling out the first.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Just for your information: you might be interested in the strtok[^] function. It could ease your life a lot in this case
|
|
|
|
|
I can't tell you how many times I've tried to find this function - I KNEW there had to be one...
I always looked at the list of "String Manipulation Routines", saw strtok and its description, and said to myself "What the hell is a token?"
Thankfully, I followed your link and looked at the example. You're right - this could ease my life in a LOT of cases!
Thank you, sir!
MZR
|
|
|
|
|
Hi,
In my application I need to extend the size of a NTFS volume. I use IOCTL_DISK_GROW_PARTITION to grow partition boundary this executes successfully. But after this FSCTL_EXTEND_VOLUME fails with error #87 (incorrect parameter).
Please anyone give me some idea that why this control code is failing.
Thanks
|
|
|
|
|
Hello,
I want to have a custom return value of a dialog box application.
We can change the return value by overriding ExitInstance().
Is it possible to have a string as return value? If yes how to achieve this?
Thank you..
|
|
|
|
|
The DoModal function returns an integer so you won't be able to change that (except if you create your own function to create the modla dialog). But anyway, this is in general not needed: you could simply add a function that returns you the string. The return of DoModal is used to return informatino about how the dialog has been closed to the user. It doesn't make a lot of sense to return some kind of data there.
|
|
|
|
|
Do you really want to return a string value to the OS ?
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
[My articles]
|
|
|
|
|
maybe it's called from another process ?
This signature was proudly tested on animals.
|
|
|
|
|
Do you really want to return a string value to another process?
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
[My articles]
|
|
|
|
|
nope; but maybe the OP wants to.
This signature was proudly tested on animals.
|
|
|
|