简体   繁体   English

addprintprocessor不起作用?

[英]addprintprocessor doesn't work?

I try to install my printprocesssor in my computer but it doesn't work??!! 我尝试在计算机上安装我的printprocesssor,但不起作用?

the code in below: 下面的代码:

_In_ LPTSTR pPathName;
_In_ LPTSTR pPrintProcessorName;

string strPathName = "HP1100PP.dll";
string strPrintProcessorName = "HP1100PP";

pPathName = (LPWSTR)strPathName.c_str();
pPrintProcessorName = (LPWSTR)strPrintProcessorName.c_str();

int a = AddPrintProcessor(NULL , NULL ,pPathName , pPrintProcessorName);

the output of a is 0. a的输出为0。

thanks in advance for any answer. 预先感谢您的任何回答。

Your casts to wide char strings, (LPWSTR) , don't actually make the strings be wide char strings. 您对宽字符字符串(LPWSTR)转换实际上不会使字符串成为宽字符字符串。 Your data is still ANSI and the casts are simply a means to lie to the compiler. 您的数据仍然是ANSI,而强制转换只是对编译器撒谎的一种手段。 Remove those casts. 删除那些演员。 Don't lie to the compiler. 不要骗编译器。

Then the compiler will reject your code because your text is ANSI but the function expects Unicode text. 然后,编译器将拒绝您的代码,因为您的文本是ANSI,但是该函数需要Unicode文本。 Because you compile targeting Unicode. 因为您以Unicode为目标进行编译。 This is the error that your untruthful casts suppressed. 这是您不忠实的演员制止的错误。 You need to deal with it properly by correcting the type mis-match. 您需要通过更正类型不匹配来正确处理它。 So either switch to wstring or call AddPrintProcessorA . 因此,要么切换到wstring要么调用AddPrintProcessorA I suggest the former. 我建议前者。

I would also suggest not using TCHAR and related types. 我也建议不要使用TCHAR和相关类型。 That was useful when you targeted Win98 which did not support Unicode but those days are long gone. 当您针对不支持Unicode的Win98,但那段日子已经过去了,那将很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM