Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Compiler construction 为什么dev.dmCopies返回编译器错误?_Compiler Construction_Mingw_Dev Mode - Fatal编程技术网

Compiler construction 为什么dev.dmCopies返回编译器错误?

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(

我正在做一个在信封上打印地址的程序。作为程序的一部分,我需要更改一些默认打印设置,例如纸张大小。为此,我使用下面列出的DocumentProperties代码

 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*'`