Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-08

Missing Win32 Function

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Okay, I've found another Win32 API function that's not supported by 1.0.6 -- EnumPrinters. According to the API Reference that function can give a list of local and/or network printers connected to your computer. I found it (well, I found EnumPrintersW) in the spoolss.dll file, so I just added a function using eternal. My program compiles fine now but I get no output on the display when I try to check the data returned by the function. I can't even get a writeln to work!

My command line looks like this:

ppc386 -OG3 -WC -vehnw -Xs -XX -Sd -FE\fpc\compiled \Source\%1 -T%2 %3 %4 %5 %6 %7 %8 %9

I've attached a small .pas test file that will demonstrate the problem (BTW; I'm using Win2K Pro).

TIA...

Jim

Reply by email

Marco van de Voort
to Unknown author
Show quoted text 7 lines
Okay, I've found another Win32 API function that's not supported by 1.0.6 -- EnumPrinters. According to the API Reference that function can give a list of local and/or network printers connected to your computer. I found it (well, I found EnumPrintersW) in the spoolss.dll file, so I just added a function using eternal. My program compiles fine now but I get no output on the display when I try to check the data returned by the function. I can't even get a writeln to work!

I don't know if I mailed this before, but if you need Windows API's, you might check out this link:

http://members.chello.nl/m.vanbrakel2/ (specially the win32api.zip)

I manage to get about 95-99% compiled of the above (>7 MB) winapi headers using the 1.1 compiler.

I use this specially at my parttime work (w2k sysadmin) to implement special functionality.

Reply by email

Unknown author
I don't know if I mailed this before, but if you need Windows API's, you might check out this link: http://members.chello.nl/m.vanbrakel2/ (specially the win32api.zip)

I just DL'd this file and took a look at it, at while it's a very elaborate and detailed piece of work, I'm not certain how it can help me. Can you elaborate on how you have used it?

Jim

Reply by email

Marco van de Voort
to Unknown author
Show quoted text 9 lines
> I don't know if I mailed this before, but if you need Windows > API's, you might check out this link: > http://members.chello.nl/m.vanbrakel2/ (specially the win32api.zip) I just DL'd this file and took a look at it, at while it's a very elaborate and detailed piece of work, I'm not certain how it can help me. Can you elaborate on how you have used it?

I compiled it, but with version 1.1.

If you have a lot of work to do that requires win2000 API's, I'm afraid you have to start trailing the development version compiler.

I'm not 100% sure that the spoolss api is in it, but in general, most of the functions missing from the ordinary windows unit are in it.

Reply by email

Unknown author

Well, I don't know that I would classify Marco's response as useless, but I must admit I still don't have an answer to my problem. The package he pointed me to is indeed comprehensive, but all I want to know is why this one function isn't returning anything. I mean the writlen should at least work, and in the example I sent it doesn't. Something is way wrong, but it's most likely me...

Martyn Ranyard
08/08/2002 09:51 PM

To: ,
cc:
Subject: Re: [fpc-pascal]Missing Win32 Function

Show quoted text 7 lines
> I don't know if I mailed this before, but if you need Windows > API's, you might check out this link: > > http://members.chello.nl/m.vanbrakel2/ (specially the win32api.zip) I just DL'd this file and took a look at it, at while it's a very elaborate and detailed piece of work, I'm not certain how it can help

me.

Can you elaborate on how you have used it?

In a reply to this email, Marco van de vort mentioned spoolss, and no doubt
this info is useless too, but Samba implements spoolss and you might find converting it to pascal is easier than calling the Win32 api.

Jim

Martyn

Reply by email

Full_Name
to Unknown author: Okay, I've found another Win32 API function that's not supported by 1.0.6 --…

Jim,

compiling this in Delphi, I found that some stuff was a bit wrong. I didn't get any valid results, but then I'm on a network without a local printer.

Try the following. Straight from the Delphi unit, so may need tweaking for your needs. I can supply the Win32 C API version if it helps.

This is from the delphi Printers Unit, so will need de-Delphifying for FPC:

function TPrinter.GetPrinters: TStrings;
var
  LineCur, Port: PChar;
  Buffer, PrinterInfo: PChar;
  Flags, Count, NumInfo: DWORD;
  I: Integer;
  Level: Byte;
begin
  if FPrinters = nil then
  begin
    FPrinters := TStringList.Create;
    Result := FPrinters;
    try
      if Win32Platform = VER_PLATFORM_WIN32_NT then
      begin
        Flags := PRINTER_ENUM_CONNECTIONS or PRINTER_ENUM_LOCAL;
        Level := 4;
      end
      else
      begin
        Flags := PRINTER_ENUM_LOCAL;
        Level := 5;
      end;
      Count := 0;
      EnumPrinters(Flags, nil, Level, nil, 0, Count, NumInfo);
      if Count = 0 then Exit;
      GetMem(Buffer, Count);
      try
        if not EnumPrinters(Flags, nil, Level, PByte(Buffer), Count, Count,
NumInfo) then
          Exit;
        PrinterInfo := Buffer;
        for I := 0 to NumInfo - 1 do
        begin
          if Level = 4 then
            with PPrinterInfo4(PrinterInfo)^ do
            begin
              FPrinters.AddObject(pPrinterName,
                TPrinterDevice.Create(nil, pPrinterName, nil));
              Inc(PrinterInfo, sizeof(TPrinterInfo4));
            end
          else
            with PPrinterInfo5(PrinterInfo)^ do
            begin
              LineCur := pPortName;
              Port := FetchStr(LineCur);
              while Port^  #0 do
              begin
                FPrinters.AddObject(Format(SDeviceOnPort, [pPrinterName, Port]),
                  TPrinterDevice.Create(nil, pPrinterName, Port));
                Port := FetchStr(LineCur);
              end;
              Inc(PrinterInfo, sizeof(TPrinterInfo5));
            end;
        end;
      finally
        FreeMem(Buffer, Count);
      end;
    except
      FPrinters.Free;
      FPrinters := nil;
      raise;
    end;
  end;
  Result := FPrinters;
end;

Hope that helps,

Matt

"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." Kristian Wilson, Nintendo, Inc, 1989 -----BEGIN GEEK CODE BLOCK----- Version: 3.12 GCS d? s+++:+ a- C++ UL+ P L++ E---- W- N+ o+ K- w O- M V PS PE-- Y PGP- t- 5-- X- R- tv+ b+ DI++ D+ G e++ h--- r+++ y+++ ------END GEEK CODE BLOCK------

Reply by email

Martyn Ranyard
to Unknown author: I just DL'd this file and took a look at it, at while it's a very elaborate and detailed…
Show quoted text 8 lines
> I don't know if I mailed this before, but if you need Windows > API's, you might check out this link: > > http://members.chello.nl/m.vanbrakel2/ (specially the win32api.zip) I just DL'd this file and took a look at it, at while it's a very elaborate and detailed piece of work, I'm not certain how it can help me. Can you elaborate on how you have used it?

In a reply to this email, Marco van de vort mentioned spoolss, and no doubt this info is useless too, but Samba implements spoolss and you might find converting it to pascal is easier than calling the Win32 api.

Jim

Martyn

Reply by email