Compiler construction 为什么dev.dmCopies返回编译器错误?
我正在做一个在信封上打印地址的程序。作为程序的一部分,我需要更改一些默认打印设置,例如纸张大小。为此,我使用下面列出的DocumentProperties代码Compiler construction 为什么dev.dmCopies返回编译器错误?,compiler-construction,mingw,dev-mode,Compiler Construction,Mingw,Dev Mode,我正在做一个在信封上打印地址的程序。作为程序的一部分,我需要更改一些默认打印设置,例如纸张大小。为此,我使用下面列出的DocumentProperties代码 HANDLE hPrinter; char pDevice[35]; strcpy(pDevice,"Test"); PRINTDLG pd; string name; ofstream print; memset( &pd, 0, sizeof( pd ) ); pd.lStructSize = sizeof(
HANDLE hPrinter;
char pDevice[35];
strcpy(pDevice,"Test");
PRINTDLG pd;
string name;
ofstream print;
memset( &pd, 0, sizeof( pd ) );
pd.lStructSize = sizeof( pd );
pd.Flags = PD_RETURNDC;
OpenPrinter(pDevice,&hPrinter,NULL);
DWORD dwNeeded = ::DocumentProperties(NULL, hPrinter, pDevice, NULL, NULL, 0);
cout << dwNeeded << endl;
PDEVMODE dev = (PDEVMODE)::malloc(dwNeeded);
cout << "2" << endl;
DocumentProperties(NULL, hPrinter, pDevice, dev, NULL, DM_OUT_BUFFER);
cout << "3" << endl;
cout << "3b" << endl;
dev.dmFields |= DM_COPIES; // define the number of copies as 3
cout << "4" << endl;
dev.dmCopies = 3; // define, which field was changed
cout << "5" << endl;
DocumentProperties(NULL, hPrinter, pDevice, dev, dev, DM_IN_BUFFER | DM_OUT_BUFFER);
cout << "set" << endl;`
我已经尝试将dev.dmCopies和dev.dmFields更改为dev->dmCopies和dev->dmFields,但是程序刚到3b,就退出了。根据MSDN,这些字段应该可以工作,所以我不知道为什么会出现这些错误:
main.cpp:98:10: error: request for member 'dmFields' in 'dev', which is of non-class type 'DEVMODEA*'
main.cpp:100:19: error: request for member 'dmCopies' in 'dev', which is of non-class type 'DEVMODEA*'`