Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Ontogeny recapitulates phylogeny.


devel / comp.lang.c / OT: Windows. List of printers? Registry or API call?

SubjectAuthor
* OT: Windows. List of printers? Registry or API call?T
+* Re: OT: Windows. List of printers? Registry or API call?Bart
|+- Re: OT: Windows. List of printers? Registry or API call?T
|`* Re: OT: Windows. List of printers? Registry or API call?T
| `- Re: OT: Windows. List of printers? Registry or API call?T
+- Re: OT: Windows. List of printers? Registry or API call?Chris M. Thomasson
`* Re: OT: Windows. List of printers? Registry or API call?Mike Terry
 `- Re: OT: Windows. List of printers? Registry or API call?T

1
OT: Windows. List of printers? Registry or API call?

<sbg0u2$o4h$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17127&group=comp.lang.c++#17127

  copy link   Newsgroups: comp.lang.c
 by: T - Tue, 29 Jun 2021 20:48 UTC

Hi All,

Windows 10

Please suffer this off topic question. I am asking it here
as I know some of you may have done this before in
one of your programs.

When a program gets a list of printers on the system to print to, is the
list coming from a registry read or from an API call? If the registry,
would you happen to remember from
where? If an API call, would you happen to know which
one you called?

Many thanks,
-T

Re: OT: Windows. List of printers? Registry or API call?

<F%LCI.211704$_jR.49482@fx14.ams4>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17128&group=comp.lang.c++#17128

  copy link   Newsgroups: comp.lang.c
 by: Bart - Tue, 29 Jun 2021 21:10 UTC

On 29/06/2021 21:48, T wrote:
> Hi All,
>
> Windows 10
>
> Please suffer this off topic question.  I am asking it here
> as I know some of you may have done this before in
> one of your programs.
>
> When a program gets a list of printers on the system to print to, is the
> list coming from a registry read or from an API call? If the registry,
> would you happen to remember from
> where?  If an API call, would you happen to know which
> one you called?
>
> Many thanks,
> -T

I saw this:

https://docs.microsoft.com/en-us/windows/win32/printdocs/enumprinters

However the last time I needed this, I used:

https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprofilestringa

(GetProfileString.) It says it's for 16-bit Windows, but still works
fine on Win64.

I think you use "devices" as the first parameter, which might have been
the name of the relevant section of win.ini.

Example:

--------------------------
#include <stdio.h>
#include <windows.h>

void listprinters(void) {
char buffer[10000];
char value[1024];
char* p;

if (!GetProfileString("devices",NULL,"",buffer,sizeof(buffer)))
return;

p=buffer;

while (*p) {
puts(p);
if (GetProfileString("devices",p,"",value,sizeof(value))) {
printf(" %s\n",value);
}
do ++p; while (*p);
++p;
}
}

int main(void) {
listprinters();
} ---------------------------

The call in the nested loop gives info on drivername and portname.

Re: OT: Windows. List of printers? Registry or API call?

<sbg32q$697$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17129&group=comp.lang.c++#17129

  copy link   Newsgroups: comp.lang.c
 by: T - Tue, 29 Jun 2021 21:24 UTC

On 6/29/21 2:10 PM, Bart wrote:
> On 29/06/2021 21:48, T wrote:
>> Hi All,
>>
>> Windows 10
>>
>> Please suffer this off topic question.  I am asking it here
>> as I know some of you may have done this before in
>> one of your programs.
>>
>> When a program gets a list of printers on the system to print to, is
>> the list coming from a registry read or from an API call? If the
>> registry, would you happen to remember from
>> where?  If an API call, would you happen to know which
>> one you called?
>>
>> Many thanks,
>> -T
>
> I saw this:
>
> https://docs.microsoft.com/en-us/windows/win32/printdocs/enumprinters
>
> However the last time I needed this, I used:
>
> https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprofilestringa
>
>
> (GetProfileString.) It says it's for 16-bit Windows, but still works
> fine on Win64.
>
> I think you use "devices" as the first parameter, which might have been
> the name of the relevant section of win.ini.
>
> Example:
>
> --------------------------
> #include <stdio.h>
> #include <windows.h>
>
> void listprinters(void) {
>     char buffer[10000];
>     char value[1024];
>     char* p;
>
>     if (!GetProfileString("devices",NULL,"",buffer,sizeof(buffer)))
>         return;
>
>     p=buffer;
>
>     while (*p) {
>         puts(p);
>         if (GetProfileString("devices",p,"",value,sizeof(value))) {
>             printf("    %s\n",value);
>         }
>         do ++p; while (*p);
>         ++p;
>     }
> }
>
> int main(void) {
>     listprinters();
> }
> ---------------------------
>
> The call in the nested loop gives info on drivername and portname.

THANK YOU!!

Re: OT: Windows. List of printers? Registry or API call?

<sbg5ln$m39$2@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17130&group=comp.lang.c++#17130

  copy link   Newsgroups: comp.lang.c
 by: Chris M. Thomasson - Tue, 29 Jun 2021 22:08 UTC

On 6/29/2021 1:48 PM, T wrote:
> Hi All,
>
> Windows 10
>
> Please suffer this off topic question.  I am asking it here
> as I know some of you may have done this before in
> one of your programs.
>
> When a program gets a list of printers on the system to print to, is the
> list coming from a registry read or from an API call? If the registry,
> would you happen to remember from
> where?  If an API call, would you happen to know which
> one you called?

Well, windows has a nice list of registry API's that do a lot with the
DB. Iirc, its a tree structure:

https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-functions

Re: OT: Windows. List of printers? Registry or API call?

<sbhl7r$ifi$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17132&group=comp.lang.c++#17132

  copy link   Newsgroups: comp.lang.c
 by: T - Wed, 30 Jun 2021 11:40 UTC

On 6/29/21 2:10 PM, Bart wrote:
> On 29/06/2021 21:48, T wrote:
>> Hi All,
>>
>> Windows 10
>>
>> Please suffer this off topic question.  I am asking it here
>> as I know some of you may have done this before in
>> one of your programs.
>>
>> When a program gets a list of printers on the system to print to, is
>> the list coming from a registry read or from an API call? If the
>> registry, would you happen to remember from
>> where?  If an API call, would you happen to know which
>> one you called?
>>
>> Many thanks,
>> -T
>
> I saw this:
>
> https://docs.microsoft.com/en-us/windows/win32/printdocs/enumprinters
>
> However the last time I needed this, I used:
>
> https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprofilestringa
>
>
> (GetProfileString.) It says it's for 16-bit Windows, but still works
> fine on Win64.
>
> I think you use "devices" as the first parameter, which might have been
> the name of the relevant section of win.ini.
>
> Example:
>
> --------------------------
> #include <stdio.h>
> #include <windows.h>
>
> void listprinters(void) {
>     char buffer[10000];
>     char value[1024];
>     char* p;
>
>     if (!GetProfileString("devices",NULL,"",buffer,sizeof(buffer)))
>         return;
>
>     p=buffer;
>
>     while (*p) {
>         puts(p);
>         if (GetProfileString("devices",p,"",value,sizeof(value))) {
>             printf("    %s\n",value);
>         }
>         do ++p; while (*p);
>         ++p;
>     }
> }
>
> int main(void) {
>     listprinters();
> }
> ---------------------------
>
> The call in the nested loop gives info on drivername and portname.

This looks like what you did:

https://docs.microsoft.com/en-us/dotnet/api/system.drawing.printing.printersettings.installedprinters?redirectedfrom=MSDN&view=net-5.0#System_Drawing_Printing_PrinterSettings_InstalledPrinters

Re: OT: Windows. List of printers? Registry or API call?

<sbi56g$ih8$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17134&group=comp.lang.c++#17134

  copy link   Newsgroups: comp.lang.c
 by: T - Wed, 30 Jun 2021 16:13 UTC

On 6/30/21 4:40 AM, T wrote:
> On 6/29/21 2:10 PM, Bart wrote:
>> On 29/06/2021 21:48, T wrote:
>>> Hi All,
>>>
>>> Windows 10
>>>
>>> Please suffer this off topic question.  I am asking it here
>>> as I know some of you may have done this before in
>>> one of your programs.
>>>
>>> When a program gets a list of printers on the system to print to, is
>>> the list coming from a registry read or from an API call? If the
>>> registry, would you happen to remember from
>>> where?  If an API call, would you happen to know which
>>> one you called?
>>>
>>> Many thanks,
>>> -T
>>
>> I saw this:
>>
>> https://docs.microsoft.com/en-us/windows/win32/printdocs/enumprinters
>>
>> However the last time I needed this, I used:
>>
>> https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprofilestringa
>>
>>
>> (GetProfileString.) It says it's for 16-bit Windows, but still works
>> fine on Win64.
>>
>> I think you use "devices" as the first parameter, which might have
>> been the name of the relevant section of win.ini.
>>
>> Example:
>>
>> --------------------------
>> #include <stdio.h>
>> #include <windows.h>
>>
>> void listprinters(void) {
>>      char buffer[10000];
>>      char value[1024];
>>      char* p;
>>
>>      if (!GetProfileString("devices",NULL,"",buffer,sizeof(buffer)))
>>          return;
>>
>>      p=buffer;
>>
>>      while (*p) {
>>          puts(p);
>>          if (GetProfileString("devices",p,"",value,sizeof(value))) {
>>              printf("    %s\n",value);
>>          }
>>          do ++p; while (*p);
>>          ++p;
>>      }
>> }
>>
>> int main(void) {
>>      listprinters();
>> }
>> ---------------------------
>>
>> The call in the nested loop gives info on drivername and portname.
>
>
> This looks like what you did:
>
> https://docs.microsoft.com/en-us/dotnet/api/system.drawing.printing.printersettings.installedprinters?redirectedfrom=MSDN&view=net-5.0#System_Drawing_Printing_PrinterSettings_InstalledPrinters
>
>

Except it is a .net call. Damn.

Re: OT: Windows. List of printers? Registry or API call?

<A66dnZnopvs9P0H9nZ2dnUU78R_NnZ2d@brightview.co.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17136&group=comp.lang.c++#17136

  copy link   Newsgroups: comp.lang.c
 by: Mike Terry - Wed, 30 Jun 2021 16:58 UTC

On 29/06/2021 21:48, T wrote:
> Hi All,
>
> Windows 10
>
> Please suffer this off topic question.  I am asking it here
> as I know some of you may have done this before in
> one of your programs.
>
> When a program gets a list of printers on the system to print to, is the
> list coming from a registry read or from an API call? If the registry,
> would you happen to remember from
> where?  If an API call, would you happen to know which
> one you called?
>
> Many thanks,
> -T

Bart pointed out the EnumPrinters API. That literally answers how you
can enumerate the available printers in your program.

Maybe you would be better with using the Windows common print dialog,
which enables the user to select the printer they want, and change the
usual print settings (...as I understand it - I think I used this once,
but it would have been at least 15 years ago...) Anyway, the provided
dialog will probably look more familiar for your users than something
you spend ages on writing yourself! And you won't need to know where
the printer list came from. You could start here:

<https://docs.microsoft.com/en-us/windows/win32/dlgbox/print-dialog-box>

Mike.

Re: OT: Windows. List of printers? Registry or API call?

<sbko40$jcn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17160&group=comp.lang.c++#17160

  copy link   Newsgroups: comp.lang.c
 by: T - Thu, 1 Jul 2021 15:48 UTC

On 6/30/21 9:58 AM, Mike Terry wrote:
> On 29/06/2021 21:48, T wrote:
>> Hi All,
>>
>> Windows 10
>>
>> Please suffer this off topic question.  I am asking it here
>> as I know some of you may have done this before in
>> one of your programs.
>>
>> When a program gets a list of printers on the system to print to, is
>> the list coming from a registry read or from an API call? If the
>> registry, would you happen to remember from
>> where?  If an API call, would you happen to know which
>> one you called?
>>
>> Many thanks,
>> -T
>
> Bart pointed out the EnumPrinters API.  That literally answers how you
> can enumerate the available printers in your program.
>
> Maybe you would be better with using the Windows common print dialog,
> which enables the user to select the printer they want, and change the
> usual print settings (...as I understand it - I think I used this once,
> but it would have been at least 15 years ago...)  Anyway, the provided
> dialog will probably look more familiar for your users than something
> you spend ages on writing yourself!  And you won't need to know where
> the printer list came from.  You could start here:
>
>   <https://docs.microsoft.com/en-us/windows/win32/dlgbox/print-dialog-box>
>
>
> Mike.
>

I have a program that read CUPS in Linux and lists the printers CUPS
sees. I want to add to the program
such that it does the same thing for Windows.

I am literally only after the list of the printers.
This is because Windows 10, in its Devices and printers,
will not always show installed printers. It is a total
pain in the ass. You can open any program with a print
dialog and find the missing ones. Now I could always
just do it that way rather than writing a program to
show me, but where is the fun in that?

Bart's response looks exactly like what I need. And
I am loath to use anything from .net for something
like this.

-T

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor