I'm looking for a way to find the name of the Windows default printer using unmanaged C++ (found plenty of .NET examples, but no success unmanaged). Thanks.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
Unmanaged C++ doesn't exist (and managed C++ is now C++/CLI), if you are referring to C++, using unmanaged as a tag is just sad...
Here is how to get a list of current printers and the default one if there is one set as the default.
Also note: getting zero for the default printer name length is valid if the user has no printers or has not set one as default.
Also being able to handle long printer names should be supported so calling GetDefaultPrinter with NULL as a buffer pointer first will return the name length and then you can allocate a name buffer big enough to hold the name.
GetDefaultPrinter (MSDN) ought to do the trick. That will get you the name to pass to CreateDC for printing.
How to retrieve and set the default printer in Windows:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;246772
Code from now-unavailable article:
The following works great for printing with the win32api from C++
In the future instead of googling "unmanaged" try googling "win32 /subject/" or "win32 api /subject/"