From: Sean Kendrick Subject: Quickie programs, and windows...need help soon. Date: 29 Mar 1999 00:00:00 GMT Message-ID: <36FFF65D.F60DA558@brailleplanet.org> Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: BraillePlanet Mime-Version: 1.0 Newsgroups: borland.public.delphi.winapi Um, okay, i have thus discovered that the ability of the "quickie" program has been abolished by windows, unless i'm missing something. In old turbo 7 i could just jump in create a program, compile it and run it, no worry about packages and thousands of units, of stuff being put in unnecessarily. My problem is this. i need to make a quick, program that only uses the TStringList class. nothing else. don't need any forms, don't need any display. it's a console application, used solely by parameters from a dos 32 bit app, to handle the printer in windows. However, when i remove all the runtime packages, and such, it still compiles in the Windows.pas unit, which i don't think i really need, since it doesn't use any windows related stuff, save what is in the WinSpool.pas unit. And currently when i try to create the stringlist class, i get an access violation. here is my code, i'm wondering if i need the application.initialize or something to be put in there. or if there is some other memory setup i need to call to make a SMALL quick application that sends to the printer without any BS. (this app compiled to 281k which is obscene for what i'm trying to do... thanks for the help. fluffy/sean kendrick {start code} program Embossit; uses Classes, WinSpool, FlufStuf; var BFMFile: TStringList; ParamStartError: Integer; F: Text; NewPort, OldPort: String; Function UpperCase(St: String): String; var I: Integer; begin For I:=1 to Length(St) do if St[I] in ['a'..'z'] then St[I]:=Char(Ord(St[I]) - 32); Result:=St; end; Function FileExists(Name: String): Boolean; var F: File; begin AssignFile(F, Name); {$I-} Reset(F); {$I+} Result:=IOresult = 0; if Result then Close(F); end; Function ParamStart: Boolean; var St: String; begin Result:=False; OldPort:=''; ParamStartError:=5; if (ParamCount < 2) or (UpperCase(ParamStr(1)) <> '/MEGA') then Exit; St:=ParamStr(2); Dec(ParamStartError); if Not PrinterExists(PrinterName) then //PrinterName = 'Generic / Text Only' and printerexists is a //simple function using the printer var from delphi. Exit; Dec(ParamStartError); NewPort:=UpperCase(ParamStr(3)); if (NewPort <> '') and (Length(NewPort) > 3) then begin NewPort:=NewPort+':'; OldPort:=SetPrinterPort(PrinterName, NewPort); //this is my proc that uses the API functions to //set the printer port. it returns the current port // in string form if NewPort = '' then Exit; end; Dec(ParamStartError); if UpperCase(ParamStr(1)) = '/MEGA' then begin Result:=FileExists(St); if Result then begin BFMFile:=BFMFile.Create; BFMFile.LoadFromFile(St); ParamStartError:=1; end; end; end; procedure BrailleIt; var St: String; PrnHandle: LongWord; DocInfo: Doc_Info_1; LineLen, BytesWritten: LongWord; I: Integer; begin I:=0; if Not OpenPrinter(PChar(PrinterName), PrnHandle, nil) then Exit; try if StartDocPrinter(PrnHandle, 1, @DocInfo) = 0 then Exit; For I:=0 to BFMFile.Count - 1do begin St:=BFMFile[I]; LineLen:=Length(St); If Not WritePrinter(PrnHandle, @St[1], LineLen, BytesWritten) or (LineLen <> BytesWritten) then Exit; end; I:=BFMFile.Count; finally if I = BFMFile.Count then ParamStartError:=0; EndDocPrinter(PrnHandle); ClosePrinter(PrnHandle); if OldPort <> '' then SetPrinterPort(PrinterName, OldPort); end; end; begin if ParamStart then BrailleIt; Exitcode:=ParamStartError; AssignFile(F, 'megaprn.err'); Rewrite(F); Writeln(F, ParamStartError); CloseFile(F); end.