Re: [Lazarus] WSRegister error on console application
Solved, thanks to all. Now I use just Windows unit (without interfaces). andrea Paul Ishenin ha scritto: 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 -- Dr. Andrea Mauri, PhD Milano Chemometrics and QSAR Research Group Department of Environmental Sciences University of Milano-Bicocca P.zza della Scienza, 1 20126 Milano - Italy Tel: ++39 02 64482801 mailto:andrea.mauri...@gmail.com http://michem.disat.unimib.it/chm/ ___ 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 (sd0) 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 (IN) do begin ifp:=PIFRec(PByte(ifc.ifcu_buf)+i); move(ifp^.ifr_ifrn.ifrn_name,ifr.ifr_ifrn.ifrn_name,IF_NAMESIZE); StrPLCopy(ifr.ifr_ifrn.ifrn_name, 'eth0', IF_NAMESIZE); if (fpioctl(sd, SIOCGIFHWADDR, @ifr) = 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;
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
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
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] 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
I still have to check it, I will try to use only the non visual units. I will post how I will solve it. andrea Andrea Mauri ha scritto: thanks to all, andrea Mattias Gaertner ha scritto: On Fri, 24 Apr 2009 19:22:35 +0200 Vincent Snijders vincent.snijd...@gmail.com wrote: Andrea Mauri schreef: Dear all, I have a cross-platform console application project. The project were compiled with no problem but actually when I compile it I get the following errors (WinXp lazarus svn fpc 2.2.4). I got this error both with fpc 2.2.2 and fpc 2.2.4, I don't know exactly when this error appears (the svn revision number of lazarus). Suggestions? Remove the dependency on the LCL. Or if it must depend on the LCL, include uses interfaces to the main program. or use only the non visual units. For example lclproc, translations, etc. Mattias ___ 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
[Lazarus] WSRegister error on console application
Dear all, I have a cross-platform console application project. The project were compiled with no problem but actually when I compile it I get the following errors (WinXp lazarus svn fpc 2.2.4). I got this error both with fpc 2.2.2 and fpc 2.2.4, I don't know exactly when this error appears (the svn revision number of lazarus). Suggestions? Best regards, Andrea Error: Undefined symbol: WSRegisterCustomImageList Error: Undefined symbol: WSRegisterMenuItem Error: Undefined symbol: WSRegisterMenu Error: Undefined symbol: WSRegisterMainMenu Error: Undefined symbol: WSRegisterPopupMenu Error: Undefined symbol: WSRegisterDragImageList Error: Undefined symbol: WSRegisterControl Error: Undefined symbol: WSRegisterWinControl Error: Undefined symbol: WSRegisterGraphicControl Error: Undefined symbol: WSRegisterCustomControl Error: Undefined symbol: WSRegisterScrollingWinControl Error: Undefined symbol: WSRegisterScrollBox Error: Undefined symbol: WSRegisterCustomFrame Error: Undefined symbol: WSRegisterCustomForm Error: Undefined symbol: WSRegisterHintWindow ___ 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: Dear all, I have a cross-platform console application project. The project were compiled with no problem but actually when I compile it I get the following errors (WinXp lazarus svn fpc 2.2.4). I got this error both with fpc 2.2.2 and fpc 2.2.4, I don't know exactly when this error appears (the svn revision number of lazarus). Suggestions? Remove the dependency on the LCL. Or if it must depend on the LCL, include uses interfaces to the main program. Vincent ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] WSRegister error on console application
On Fri, 24 Apr 2009 19:22:35 +0200 Vincent Snijders vincent.snijd...@gmail.com wrote: Andrea Mauri schreef: Dear all, I have a cross-platform console application project. The project were compiled with no problem but actually when I compile it I get the following errors (WinXp lazarus svn fpc 2.2.4). I got this error both with fpc 2.2.2 and fpc 2.2.4, I don't know exactly when this error appears (the svn revision number of lazarus). Suggestions? Remove the dependency on the LCL. Or if it must depend on the LCL, include uses interfaces to the main program. or use only the non visual units. For example lclproc, translations, etc. Mattias ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] WSRegister error on console application
thanks to all, andrea Mattias Gaertner ha scritto: On Fri, 24 Apr 2009 19:22:35 +0200 Vincent Snijders vincent.snijd...@gmail.com wrote: Andrea Mauri schreef: Dear all, I have a cross-platform console application project. The project were compiled with no problem but actually when I compile it I get the following errors (WinXp lazarus svn fpc 2.2.4). I got this error both with fpc 2.2.2 and fpc 2.2.4, I don't know exactly when this error appears (the svn revision number of lazarus). Suggestions? Remove the dependency on the LCL. Or if it must depend on the LCL, include uses interfaces to the main program. or use only the non visual units. For example lclproc, translations, etc. Mattias ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus -- Dr. Andrea Mauri, PhD Milano Chemometrics and QSAR Research Group Department of Environmental Sciences University of Milano-Bicocca P.zza della Scienza, 1 20126 Milano - Italy Tel: ++39 02 64482801 mailto:andrea.mauri...@gmail.com http://michem.disat.unimib.it/chm/ ___ 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: thanks to all, How did you solve it? Vincent ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus