Open the dial-up call call Dial-up program to connect: where 'connects Internet' to your dial-up program name Winexec ('Rundll32.exe Rnaui.dll, RNADial' 'Connecting Internet', 9); a serial communication problem? Serial Port Communications? Q. I want to build a simple electrical controller which receives input from asensor through a comm port and either turns a power source (s) on or offbased upon this signal. I want this controller to be software in nature. How do I communicate through the port and is it possible to discern changesin voltage.If not, what kind of signal must be input. A. When you want to write and read only binary signals you can use the printerparallel port. For that purpose the Port command is useful. In the below anexample of some D1 code used for bidirectional 2 wire bus communication (I2C) .BaseAddress is $ 278, $ 378 or $ 3BC, depending on the LPT port used forcommunication.There is a 'but'. In D1 the Port Function Was Available But Not Documented. Ind2 and D3 It Seem to Have Disappeared Entire (please Somebody Correct Me ifthis Is Wrong) .we Are Using The Parallel printer port with attached a small interface cardwith some I / O buffering for control of RF modules Could somebody indicatewhether the Port function still exist or what the alternative could be regards, Hans BrekelmansPROCEDURE SetIICline (Terminal: IICterminalTypes; High: Boolean);.? Var Count: Word; Ctrladdress: Word; Begin {set IIC line} ctrladdress: = baseaddress 2; Case Terminal of SCL: if high the port [ctrladdress]: = $ 08 else port [ctrladdress]: = $ 00; sda: if not high The port [baseaddress]: = $ 80 else port [baseaddress]: = $ 00; end; for count: = 1 to clockdelay do; end; {setiicline} Function GetiicLine (Terminal: iicterminalTypes): boolean; const SDA_IN = $ 80;
{SDA: 25 PIN # 11, Status, Not Busy, Bit 7} SCL_IN = $ 08; {SCL: 25 PIN # 15, Status, Not Error, Bit 3} Var Count: Word; Readaddress: Word; Begin Readdress: = BaseAddress 1; Case Terminal of SCL: GetiicLine: = ((Port [Readaddress] and SCL_IN) = SCL_IN); SDA: GetiicLine: = ((port [readaddress] and sda_in) = sda_in); {read sdapin} end; for Count : = 1 to clockdelay do; end; get the native IP address? How About Using Winsockets? This code is unnedested and ugly.program get_ip; uses winsock, sysutils; var ch: array [1..32] of char; i: INTEGER; WSDATA: TWSADATA; MYHOST: PHOSTENT; Begin IF WSASTARTUP (2, WSDATA) <> 0 THEN BEGIN WRITELN ('can''t Start Winsock: Error', Wsagetlasterror); Halt (2); End; Try if gethostname @CH [1], 32) <> 0 dam Writeln; Halt (3); End; Except Writeln; Halt (3); end; myhost: = gethostbyname (@ CH [1]); if Myhost = NIL THEN Begin Writeln (' STRPAS (@CH [1]) ') FAI LED: Error ' INTOSTR (Wsagetlasteerror); Halt (4); END ELSE BEGIN WRITE (FOR i: = 1 to 4 do begin Write (ord (myhost.h_addr ^ [i-1]))) IF i <4 THEN WRITE (') Else Writeln; end; end; end. Any Dynamic Change / Add Network Settings DNS address of TCP / IP, for example, add DNS Server's address to 192.0.0.1 and 192.1 .1.0, can be called: settcpipdnsaddresses ('192.0.0.1 192.1.1.0'); // Each address is separated from a space 1. SettcpipdnsAddresses is defined as follows: Procedure settcpipdnsaddresses (SIPS: String);
begin //// if using Windows NT // SaveStringToRegistry_LOCAL_MACHINE ( 'SYSTEM / CurrentControlSet' '/ Services / Tcpip / Parameters',' NameServer ', sIPs); //// if using Windows 95 // SaveStringToRegistry_LOCAL_MACHINE (' SYSTEM / CurrentControlSet ' ' / Services / VxD / MSTCP ',' NameServer ', sIPs); end; 2 wherein SaveStringToRegistry_LOCAL_MACHINE definitions:. uses Registry; procedure SaveStringToRegistry_LOCAL_MACHINE (sKey, sItem, sVal: string); varreg: TRegIniFile; beginreg: = TRegIniFile .Create (''); reg.rootkey: = HKEY_LOCAL_MACHINE; REG.WRITESTRING (SKEY, SITEM, SVAL # 0); reg.free; end; How to dynamically get a Win95 / 98 network neighbor in the program And computer name? You can refer to the following code, maybe help: Procedure getDomainList (TV: TtreeView); Vara: Integer; Errcode: Integer; Netres: array; enumhandle: Thandle; Enumentries: DWORD; BufferSize: DWord; s: string; itm: TTreeNode; begin {Start here} tryWith NetRes [0] do begindwScope: = RESOURCE_GLOBALNET; dwType: = RESOURCETYPE_ANY; dwDisplayType: = RESOURCEDISPLAYTYPE_DOMAIN; dwUsage: = RESOURCEUSAGE_CONTAINER; lpLocalName: = NIL; l pRemoteName: = NIL; lpComment: = NIL; lpProvider: = NIL; end; {get net root} ErrCode: = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_ANY, RESOURCEUSAGE_CONTAINER, @ NetRes [0], EnumHandle); If ErrCode = NO_ERROR then beginEnumEntries: = 1; BufferSize: = SizeOf (NetRes); ErrCode: = WNetEnumResource (EnumHandle, EnumEntries, @ NetRes [0], BufferSize); WNetCloseEnum (EnumHandle); ErrCode: = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_ANY, RESOURCEUSAGE_CONTAINER, @ NetRes [0], ENUMHANDLE: = 1024; buffersize: = sizeof (Netres); errcode: = WneetenumResource (EnumHandle, ENUMENTRIES, @ NetRes [0], buffersize);
IF errcode = no_error dam = 0; items.beginupdate; items.clear; itm: = items.add (TV.selected, string (Netres [0] .lppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppProvider); itm.imageindex: = 0; ITM.SelectedIndex: = 0; {Get Domains} The following unit defines a component. TNetworkBrowser, you can enumerate all network resources on the Hierachical tree. In fact, browsing is a long time, you can pass on Windows Open the "Overall Network" in the Explorer. If you set the scope property as NSContext, you can see the same machine list as the network neighbor .unit Netbrwsr; InterfaceUseSwindows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs; typeTNetScope = (nsConnected, nsGlobal, nsRemembered, nsContext); TNetResourceType = (nrAny, nrDisk, nrPrint); TNetDisplay = (ndDomain, ndGeneric, ndServer, ndShare, ndFile, ndGroup, ndNetwork, ndRoot, ndShareAdmin, ndDirectory, ndTree , ndNDSContainer); TNetUsage = set of (nuConnectable, nuContainer); TNetworkItems = class; TNetworkItem = classprivateFScope: TNetScope; FResourceType: TNetResourceType; FDisplay: TNetDisplay; FUsage: TNetUsage; FLocalName: string; FRemoteName: string; FComment: string; FProvider: String; FSUBITEMS: TNETWORKITEMS; Publicconstructor Creator Creator e; destructor Destroy; override; property Scope: TNetScope read FScope; property ResourceType: TNetResourceType read FResourceType; property Display: TNetDisplay read FDisplay; property Usage: TNetUsage read FUsage; property LocalName: string read FLocalName; property RemoteName: string read FRemoteName; property comment: string read FComment; property Provider: string read FProvider; property SubItems: TNetworkItems read FSubItems; end; TNetworkItems = classprivateFList: TList; procedure SetItem (Index: Integer; Value: TNetworkItem); function GetItem (Index: Integer): TNetworkItem; Function getCount: Integer; Publicconstructor Creger; Destructor Destroy; Override; Procedure Clear;
procedure Add (Item: TNetworkItem); procedure Delete (Index: Integer); property Items [Index: Integer]: TNetworkItem read GetItem writeSetItem; default; property Count: Integer read GetCount; end; TNetworkBrowser = class (TComponent) privateFItems: TNetworkItems; FScope: TNetScope; FResourceType: TNetResourceType; FUsage: TNetUsage; fActive: Boolean; procedure Refresh; procedure SetActive (Value: Boolean); procedure setScope (Value: TNetScope); procedure SetResourceType (Value: TNetResourceType); procedure SetUsage (Value: TNetUsage) ; procedure EnumerateNet (NetItems: TNetworkItems; lpnr: PNetResource); protectedpublicconstructor Create (AOwner: TComponent); override; destructor Destroy; override; procedure Open; procedure Close; property Items: TNetworkItems read FItems; publishedproperty Scope: TNetScope read FScope write setScope default NSGLOBAL; Property ResourceType: TNetResourceType Read FresourceTypewrite SetResourceType Default NRANY; Property Usage: TNetusage Read Fusage Write Setusage Default []; Property ACT ive: Boolean read FActive write SetActive default False; end; implementationtypePNetResourceArray = ^ TNetResourceArray; TNetResourceArray = array [0..0] of TNetResource; {TNetworkItem} constructor TNetworkItem.Create; begininherited; FSubItems: = TNetworkItems.Create; end; destructor TNetworkItem .Destroy; beginif FSubItems <> nil thenFSubItems.Free; inherited; end; {TNetworkItems} constructor TNetworkItems.Create; begininherited; FList: = TList.Create; end; destructor TNetworkItems.Destroy; beginClear; if FList <> nil thenFList.Free Inherited; End; Procedure TNetworkItems.SetItem (INDEX: Integer; Value: TNetworkItem); Beginif (Flist.Items [index] <> nil) and (flist.items [index] <>
. Value) thenTNetworkItem (FList.Items [Index]) Free; FList.Items [Index]: = Value; end; function TNetworkItems.GetItem (Index: Integer): TNetworkItem; beginResult: = TNetworkItem (FList.Items [Index]) ; end; procedure TNetworkItems.Clear; beginwhile Count> 0 doDelete (0); end; procedure TNetworkItems.Add (Item: TNetworkItem); beginFList.Add (Item); end; procedure TNetworkItems.Delete (Index: Integer); beginif FList .Items [Index] <> nil thenTNetworkItem (FList.Items [Index]) Free; FList.Delete (Index); end; function TNetworkItems.GetCount:. Integer; beginif FList <> nil thenResult: = FList.CountelseResult: = 0 ; end; {TNetworkBrowser} constructor TNetworkBrowser.Create (AOwner: TComponent); begininherited Create (AOwner); FItems: = TNetworkItems.Create; FScope: = nsGlobal; FResourceType: = nrAny; FUsage: = []; end; destructor TNetworkBrowser. Destroy; beginif FItems <> nil thenFItems.Free; inherited; end; procedure TNetworkBrowser.EnumerateNet (NetItems: TNetworkItems; lpnr: PNetResource); vardwResult, dwResultEnum: Integer; hEnum: THandl e; cbBuffer, cEntries, i: Integer; nrArray: PNetResourceArray; NewItem: TNetworkItem; dwScope, dwType, dwUsage: Integer; begincbBuffer: = 16384; cEntries: = $ FFFFFFFF; case FScope ofnsConnected: dwScope: = RESOURCE_CONNECTED; nsGlobal: dwScope: = RESOURCE_GLOBALNET; nsRemembered: dwScope: = RESOURCE_REMEMBERED; nsContext: dwScope: = RESOURCE_CONTEXT; elsedwScope: = RESOURCE_GLOBALNET; end; case FResourceType ofnrAny: dwType: = RESOURCETYPE_ANY; nrDisk: dwType: = RESOURCETYPE_DISK; nrPrint: dwType: = RESOURCETYPE_PRINT; elsedwType: = ResourceType_any; End; dwusage: = 0; if NuConnectable in Fusage Thendwusage: = dwusage or resourceusage_connectable;
if nuContainer in FUsage thendwUsage: = dwUsage or RESOURCEUSAGE_CONTAINER; dwResult: = WNetOpenEnum (dwScope, dwType, dwUsage, lpnr, hEnum); if dwResult <> NO_ERROR then Exit; GetMem (nrArray, cbBuffer); repeatdwResultEnum: = WNetEnumResource (hEnum, cEntries , nrArray, cbBuffer); if dwResultEnum = NO_ERROR thenfor i: = 0 to cEntries-1 dobeginNewItem: = TNetworkItem.Create; case nrArray [i] .dwScope ofRESOURCE_CONNECTED: NewItem.FScope: = nsConnected; RESOURCE_GLOBALNET: NewItem.FScope: = nsGlobal ; RESOURCE_REMEMBERED: NewItem.FScope: = nsRemembered; RESOURCE_CONTEXT: NewItem.FScope: = nsContext; elseNewItem.FScope: = nsGlobal; end; case nrArray [i] .dwType ofRESOURCETYPE_ANY: NewItem.FResourceType: = nrAny; RESOURCETYPE_DISK: NewItem.FResourceType: = nrDisk; RESOURCETYPE_PRINT: NewItem.FResourceType: = nrPrint; elseNewItem.FResourceType: = nrAny; end; case nrArray [i] .dwDisplayType ofRESOURCEDISPLAYTYPE_GENERIC: NewItem.FDisplay: = ndGeneric; RESOURCEDISPLAYTYPE_DOMAIN: NewItem.FDisplay: = ndDomain; RESOURCEDIS PLAYTYPE_SERVER: NewItem.FDisplay: = ndServer; RESOURCEDISPLAYTYPE_SHARE: NewItem.FDisplay: = ndShare; RESOURCEDISPLAYTYPE_FILE: NewItem.FDisplay: = ndFile; RESOURCEDISPLAYTYPE_GROUP: NewItem.FDisplay: = ndGroup; RESOURCEDISPLAYTYPE_NETWORK: NewItem.FDisplay: = ndNetwork; RESOURCEDISPLAYTYPE_ROOT: NewItem.FDisplay : = ndRoot; RESOURCEDISPLAYTYPE_SHAREADMIN: NewItem.FDisplay: = ndShareAdmin; RESOURCEDISPLAYTYPE_DIRECTORY: NewItem.FDisplay: = ndDirectory; RESOURCEDISPLAYTYPE_TREE: NewItem.FDisplay: = ndTree; RESOURCEDISPLAYTYPE_NDSCONTAINER: NewItem.FDisplay: = ndNDSContainer; elseNewItem.FDisplay: = ndGeneric; end; NewItem .Fusage: = [];