Re: [Lazarus] WSRegister error on console application
Paul Ishenin wrote: > Andrea Mauri wrote: > >> I tried it (replaced LCLType and LCLintf with Windows), now I got an >> error on these lines: >> NCB.ncb_command := Char(NCBENUM); >> NCB.ncb_command := Char(NCBRESET); >> NCB.ncb_command := Char(NCBASTAT); >> NCB.ncb_buffer := PChar(@Adapter); >> The error is: >> Error: Incompatible types: got "Char" expected "Byte" >> > > Well, you can replace Char by Byte. See yourself which solution is > better for you. > > You could try smart-linking -CX -XX (You will have to build the LCL smartlinkable, and your app too) That should get rid of the error. If you really only use parts (such as type declarations) that do not need the interface, then smart lining should remove all those references (and that includes all of the WSRegister* too) Martin ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] WSRegister error on console application
Andrea Mauri wrote: > I tried it (replaced LCLType and LCLintf with Windows), now I got an > error on these lines: > NCB.ncb_command := Char(NCBENUM); > NCB.ncb_command := Char(NCBRESET); > NCB.ncb_command := Char(NCBASTAT); > NCB.ncb_buffer := PChar(@Adapter); > The error is: > Error: Incompatible types: got "Char" expected "Byte" Well, you can replace Char by Byte. See yourself which solution is better for you. Best regards, Paul Ishenin. ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Lazarus IDE crash on Centos 5.3 x86
Finish i can solve my problem. Lazarus 0.9.27 r19639 from daily snapshot, work in a local gnome session on the server, but not work in a gnome session started from a sunray thin client. Lazarus 0.9.26.2 work well on both. Thanks to all!! -- Carlos Germán Tejero ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Editor font disturbed after upgrading to r19705
@Paul: Something else I noticed. Can there be a relationship between this and bug http://bugs.freepascal.org/view.php?id=13062 (IDE prints garbage on screen)? I ask this because I noticed that the broken version produced lots of garbage on the screen, and after your fix, this has been reduced (not gone though). It seems to be a win9x issue only (so hardly anyone seems to bother). Bart ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] WSRegister error on console application
Andrea Mauri schreef: > If I add Interfaces to the main unit the project compiles fine. But is > it ok to add interfaces to a console application? If it can be prevented, I would not do it, but it is OK. Note that it would require a display on linux, for example. > I need two LCL unit, LCLtype and LCLintf. I use this unit in order to > get the mac address on windows (using netapi32.dll). If LCLType and LCLIntf are used only on the windows OS, then I would replace them with the windows unit, to prevent a dependency on the LCL widgetset interface. > uses > Classes, SysUtils > {$IFDEF MSWINDOWS} > , snmp, nb30, dynlibs, LCLtype, LCLintf, LCLProc snmp, nb30, dynlibs, Windows, LCLProc, > {$ENDIF MSWINDOWS} > {$IFDEF LINUX} > , baseunix, sockets, users > {$ENDIF}; > I think LCLProc can be used without the interfaces unit. Vincent ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] WSRegister error on console application
I tried it (replaced LCLType and LCLintf with Windows), now I got an error on these lines: NCB.ncb_command := Char(NCBENUM); NCB.ncb_command := Char(NCBRESET); NCB.ncb_command := Char(NCBASTAT); NCB.ncb_buffer := PChar(@Adapter); The error is: Error: Incompatible types: got "Char" expected "Byte" Regards, andrea Paul Ishenin ha scritto: > Andrea Mauri wrote: > >> If I add Interfaces to the main unit the project compiles fine. But is >> it ok to add interfaces to a console application? >> {$IFDEF MSWINDOWS} >> , snmp, nb30, dynlibs, LCLtype, LCLintf, LCLProc >> > > > It will be enough for you to replace LCLType, LCLIntf by Windows unit. > Then you can remove Interfaces dependency (maybe LCLProc depends on > Interfaces too). > > Best regards, > Paul Ishenin. > > ___ > Lazarus mailing list > Lazarus@lazarus.freepascal.org > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > > ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] WSRegister error on console application
Andrea Mauri wrote: > If I add Interfaces to the main unit the project compiles fine. But is > it ok to add interfaces to a console application? > {$IFDEF MSWINDOWS} > , snmp, nb30, dynlibs, LCLtype, LCLintf, LCLProc It will be enough for you to replace LCLType, LCLIntf by Windows unit. Then you can remove Interfaces dependency (maybe LCLProc depends on Interfaces too). Best regards, Paul Ishenin. ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] WSRegister error on console application
If I add Interfaces to the main unit the project compiles fine. But is it ok to add interfaces to a console application? I need two LCL unit, LCLtype and LCLintf. I use this unit in order to get the mac address on windows (using netapi32.dll). I found a delphi code and I modified it in order to run it on lazarus, but I didn't understand everything, I only know that actually it works. Here the code: { *** } { } {Unit containing NetBIOS 3.0 definition } { Porting of Nb30 Delphi unit to FreePascal } { And GetLoginName Function} {} { } { *** } unit my_sysinfo; {$mode objfpc}{$H+} interface uses Classes, SysUtils {$IFDEF MSWINDOWS} , snmp, nb30, dynlibs, LCLtype, LCLintf, LCLProc {$ENDIF MSWINDOWS} {$IFDEF LINUX} , baseunix, sockets, users {$ENDIF}; type TUser = record Name: string; { Username. } Passwd: string; { Password. } User_id: Cardinal;{ User ID. } Group_id: Cardinal; { Group ID. } Real_name: string;{ Real name. } Home_dir: string; { Home directory. } Shell: string;{ Shell program. } end; function GetMACAddress: string; function GetUserInfo: TUser; implementation {$IFDEF LINUX} const IF_NAMESIZE= 16; SIOCGIFCONF= $8912; SIOCGIFHWADDR = $8927; type {$packrecords c} tifr_ifrn = record case integer of 0 : (ifrn_name: array [0..IF_NAMESIZE-1] of char); end; tifmap = record mem_start : cardinal; mem_end : cardinal; base_addr : word; irq : byte; dma : byte; port : byte; end; PIFrec = ^TIFrec; TIFrec = record ifr_ifrn : tifr_ifrn; case integer of 0 : (ifru_addr : TSockAddr); 1 : (ifru_dstaddr : TSockAddr); 2 : (ifru_broadaddr : TSockAddr); 3 : (ifru_netmask : TSockAddr); 4 : (ifru_hwaddr: TSockAddr); 5 : (ifru_flags : word); 6 : (ifru_ivalue: longint); 7 : (ifru_mtu : longint); 8 : (ifru_map : tifmap); 9 : (ifru_slave : Array[0..IF_NAMESIZE-1] of char); 10 : (ifru_newname : Array[0..IF_NAMESIZE-1] of char); 11 : (ifru_data : pointer); end; TIFConf = record ifc_len : longint; case integer of 0 : (ifcu_buf : pointer); 1 : (ifcu_req : ^tifrec); end; function GetUserInfo: TUser; var Data: TPasswordRecord; begin GetUserData(FpGetuid, Data); Result.Name:= Data.pw_name; Result.Real_name:= Data.pw_gecos; Result.User_id:= Data.pw_uid; Result.Group_id:= Data.pw_gid; Result.home_dir:= Data.pw_dir; Result.shell:= Data.pw_shell; end; (* Taken and modified from macuuid unit in packages/uuid/src/macuuid.pp *) function GetMACAddress : string; var MacAddr: Packed Array[1..6] of byte = (0,0,0,0,0,0); i,n,Sd : Integer; buf : Array[0..1023] of byte; ifc : TIfConf; ifr : TIFRec; ifp : PIFRec; p : PChar; MACaddress: string; Found: boolean; begin Found:= False; Result:= ''; sd:=fpSocket(AF_INET,SOCK_DGRAM,IPPROTO_IP); if (sd<0) then exit; Try ifc.ifc_len:=Sizeof(Buf); ifc.ifcu_buf:=...@buf; if fpioctl(sd, SIOCGIFCONF, @ifc)<0 then Exit; n:= ifc.ifc_len; i:=0; While (Not Found) and (I= 0) then begin P:=Pchar(@ifr.ifru_hwaddr.sa_data); Found:=(p[0]<>#0) or (p[1]<>#0) or (p[2]<>#0) or (p[3]<>#0) or (p[4]<>#0) or (p[5]<>#0); If Found Then begin Move(P^,MacAddr,SizeOf(MacAddr)); end; end; I:=I+sizeof(tifrec); end; Finally fileClose(sd); MACaddress:= ''; For i:=1 to 5 do MACaddress:= MACaddress + hexstr(MacAddr[i],2) + ':'; Result:= MACaddress + hexstr(MacAddr[6],2); end; end; {$ENDIF} {$IFDEF MSWINDOWS} type TNetBios = function(P: PNCB): Byte; stdcall; var NetBiosLib: HINST = 0; _NetBios: TNetBios; function AdapterToString(Adapter: PByteArray): string; begin Result := Format('%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x', [Adapter^[0], Adapter^[1], Adapter^[2], Adapter^[3], Adapter^[4], Adapter^[5]]); end; function GetMacAddresses(const Machine: string; const Addresses: TStringList): Integer; procedure ExitNetbios; begin if NetBiosLib <> 0 then begin FreeLibrary(NetBiosLib); NetBiosLib := 0; end; end; function InitNetbios: Boolean; begin Result := True; if NetBiosLib = 0 then begin NetBiosLib := LoadLibrary(PChar('netapi32.dll')); Result := NetBiosLib <> 0; if Result then