Here you can find types and functions which can be used in all types of scripts. Except this
possible use the standard types and function of the pascal for work with strings, for instance such functions as
Copy, Delete and type TStringList. Also it is possible use the functions from external .dll libraries.
For this such function shoud be declared at the beginning of the script program approximately as follows:
function FindWindow(C1, C2: PChar): Longint; external 'FindWindowA@user32.dll stdcall';
- type TDateTime
- function EncodeDate(Year, Month, Day: Word): TDateTime;
- function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;
- function TryEncodeDate(Year, Month, Day: Word; var Date: TDateTime):
Boolean;
- function TryEncodeTime(Hour, Min, Sec, MSec: Word; var Time: TDateTime):
Boolean;
- procedure DecodeDate(const DateTime: TDateTime; var Year, Month, Day:
Word);
- procedure DecodeTime(const DateTime: TDateTime; var Hour, Min, Sec,
MSec: Word);
- function DayOfWeek(const DateTime: TDateTime): Word;
- function Date: TDateTime;
- function Time: TDateTime;
- function Now: TDateTime;
- function DateTimeToUnix(D: TDateTime): Int64;
- function UnixToDateTime(U: Int64): TDateTime;
- function DateToStr(D: TDateTime): string;
- function StrToDate(const s: string): TDateTime;
- function FormatDateTime(const fmt: string; D: TDateTime): string;
Files, applications and settings
NetView controlling
NetView interface objects
Files, applications and settings
Type TSearchRec=record
Time:integer;
Size:integer;
SizeHigh:integer;
Attr:integer;
Name:string;
FindHandle:integer;
end;
function FindFirst(Path:string; var F:
TSearchRec):integer;
Find enumaration of files of folders by given path and search mask.
Path - File path\mask. For example 'C:\WinNT\*.exe'. If path started not by
drive letter or \\ than folder \NetView\Scripts considered as root.
F - structure where all find information will be stored
Returns 0 in case of success or error code
function FindNext(var F: TSearchRec):integer;
Continues enumeration started with FindFirst call.
Returns 0 in case of success or error code
procedure FindClose(F: TSearchRec);
Finishes file search. On every successfull FindFirst call you should call
FindClose to free allocated resources.
function CopyFile(source:string;target:string;failifexists:boolean):
integer;
Copies file. If path started not by drive letter or \\ than
folder \NetView\Scripts considered as root.
Returns 0 in case of success or error code
function MoveFile(source:string;target:string):
integer;
Moves file. If path started not by drive letter or \\ than
folder \NetView\Scripts considered as root.
Returns 0 in case of success or error code
function CreateDirectory(s:string):
integer;
Creates folder. If path started not by drive letter or \\
than folder \NetView\Scripts considered as root.
Returns 0 in case of success or error code
function RemoveDirectory(s:string):
integer;
Deletes folder. If path started not by drive letter or \\ than
folder \NetView\Scripts considered as root.
Returns 0 in case of success or error code
function DeleteFile(s:string):
integer;
Deletes file. If path started not by drive letter or \\ than
folder \NetView\Scripts considered as root.
Returns 0 in case of success or error code
function Exec(f:string;s:string;i:integer): Longint;
Executes
application\document
f: path\name to the file to execute or open
s: parameters strings. Should be empty for documents
Flags in i:
Windows cose |
Value |
Meaning |
SW_HIDE |
0 |
start hidden
|
SW_SHOWNORMAL |
1 |
start normal
|
SW_SHOWMINIMIZED |
2 |
start minimized
|
SW_SHOWMAXIMIZED |
3 |
start maximized
|
SW_SHOWNOACTIVATE |
4 |
don't activate
|
SW_SHOW |
5 |
start, opens window
|
SW_MINIMIZE |
6 |
start minimized
|
SW_SHOWMINNOACTIVE |
7 |
start minimized and not active
|
SW_SHOWNA |
8 |
start not active
|
SW_RESTORE |
9 |
start normal window
size
|
SW_SHOWDEFAULT |
10 |
start as NetView was
started
|
Bitmask flag |
128 |
wait while application
closed
|
function GetFileSize(f:Longint;var sizeh:Longint):
Longint;
Gets file's size. Get's in sizeh
higher 32 bits if file is greater than 4Gb
function CloseFile(f:Longint): Longint;
Closes
opened file.
function OpenFile(s:string; mode:Longint): Longint;
Opens file. If path started not by drive letter or \\ than folder \NetView\Scripts considered as root.
Returns file handle or 0
Flags (can be combined):
1: open for reading
2: open for writing
4: file will be created if not exists
8: file will be rewritten if exists
function ReadFile(f:Longint;n:Longint;var s:String):
Longint;
Reades n bytes from file.
Return count of read bytes
function SetFilePointer(f:Longint;pl:Longint;ph:Longint;mode:Longint):
Longint;
Sets file pointer. pl, ph - minor and major 32bits parts of offset. mode:
0 :from file beginning
1 :from current position
2 :from end of file
function WriteFile(f:Longint;s:String): Longint;
Writes string to file. Return count of read characters
procedure WriteIni(section:string;varname:string;vardata:string);
Writes string to NetView ini file. Then you will be able to read it with ReadIni.
section -ini file section name
varname -key name
vardata -string-value data
function ReadIni(section:string;varname:string;defaultdata:string):string;
Reades string, stored in NetView's ini file.
section -ini file section name
varname -key name
defaultdata -default value data
returns stored value or defaultdata if specified key not found in ini
NetView control
function Action(wparam:integer;lparam:integer):integer;
- Multifunctional procedure. Action codes in wparam:
- NVACTION_RECHECK - recheck host. lparam=host it
- (NVACTION_RECHECK or NVACTION_LIST) - recheck list. lparam=list it or NULL for total recheck
- NVACTION_RETRACE - retrace host. lparam=host it
- (NVACTION_RETRACE or NVACTION_LIST) - retrace list. lparam=list it or NULL for total retrace
- NVACTION_OPEN - opens host. lparam=host id
- NVACTION_EDIT - edit host.. lparam=host id. Returns 0 on cancel edit
- NVACTION_IMGEXPORT - Initiates visual map to gif image export
- NVACTION_SETSTATE - Updates host state. Necessary after some hosts metavariables changes.
procedure SaveHostlist(fname:string);
- Saves hostlist to file in .nvh format.
procedure LoadHostlist(fname:string);
- Loades hostlist from file in .nvh format
function GetShareList(host:string):string;
- Gets shared resources list divided by chr(13). On error returns single character chr(1)
NetView interface objects
NetView's hostlist presents itself database. Each has has an unique
identifier of the type integer, which is not changed in current session of the
work. Script can enumerate all or only selected by user hosts. General host
information such as its ID, ID of the next host in list, its name and IP
address can be accessed as fields of the TNVOST object. Other info stored in
metavariables and can be accessed by variables names.
type TNVHOST=class
(TOBJECT)
private
ID,NEXTID:integer;
COLOR:integer;
hname,hip:string;
public
procedure GETBYTEXT(txt:string;flags:integer);
procedure GETHOST(xid:integer;flags:integer);
procedure SETHOST;
procedure DELHOST;
function GETMETAVAR(varname:string):string;
procedure SETMETAVAR(varname:string;vardata:string);
procedure TRYAUTH(UseRandom:boolean);
published
constructor CREATE;
desructor FREE;
end;
- ID -Host id. Usually you has no need to change it manually.
- NEXTID - id of the next host in list. Allows enumaration of all hosts in entire hostlist
- COLOR
- hname - hostname
- hip -IP address
- GETBYTEXT(txt:string;flags:integer);
- txt -hostname or host IP by wich you want to get host information.
- flags:
- 0 -simple looks for host wich name or IP matches specified string and returns its id or 0
- NVOBJ_FORCENEW -if can't find host in list, tries to add new host and return new hos id if succeed or 0
- NVOBJ_FORCENEW or NVOBJ_HOSTNOIP - if no host found then add new host with empty IP and returns its IP
- GETHOST(xid:integer;flags:integer);
- Retrieves all info about host with id=xid. if xid=0 the get 1st host
flags:
- 0 - gets any host in list.
- NVOBJ_SELECTED - gets only selected hosts
- SETHOST - Applies all changes in TNVHOST script object to NetView
- DELHOST - Delete host
- GETMETAVAR(varname:string):string;
- Return metavariable string with name varname
- SETMETAVAR(varname:string;vardata:string)
- Sets metavariable string.
- TRYAUTH(UseRandom:boolean);
- Used to authorize self on local computer using stored in metavariables user and password or using
random-generated username
- if UseRandom = false: try authorize host with stored username and password in variables
"user" and "pass". If no user/pass stored do nothing
- if UseRandom = true:try authorize host with stored username and password in variables
"user" and "pass". If no user/pass stored try random username
- General metavariables list you can find here
type
TNVMENUITEM=class (TOBJECT)
private
public
ID,PARENTID:integer;
FLAGS:integer;
MSG:integer;
TXT:string;
procedure REFRESH;
procedure DELETE;
procedure
SPLIT;
published
constructor create;
destructor free;
end;
- ID -menu id
- PARENTID -parent menu item id or 0
- FLAGS -
- NVMENUFLAG_MAIN - menu will be appeaared in Plug-ins submenu
- NVMENUFLAG_CONTEXT - menu will be appeaared in context hostlist menu
- NVMENUFLAG_TRAY - menu will be appeaared in notification icon context menu
- NVMENUFLAG_DISABLED - menu will be disabled
- NVMENUFLAG_CHECKED - menu will be checked
- NVMENUFLAG_SORTED - menu can be sorted by calling SORT method of the parent menu
- MSG -message code wich will be sent to script on menu click. Allowed
values from $850 to $A00
- TXT -menu text
- REFRESH -addes new or updates existing menu item. To create new menu you should set all fields,
then set ID to 0 and call REFRESH.
Then you will be able t change or delete menu using REFRESH using
returned in structure ID.
- DELETE -deletes menu and sets its ID to 0
- SPLIT -splits all child menus to accomodate they on the screen
type TNVLIST=class (TOBJECT)
private
ID,NEXTID:integer;
lname,ltheme:string;
public
procedure GETBYTEXT(txt:string;flags:integer);
procedure GETLIST(xid:integer;flags:integer);
procedure SETLIST;
procedure DELLIST;
published
constructor CREATE;
end;
type TNVLINE=class (TOBJECT)
private
INDEX,COUNT:integer;
nodes,color,flags,width:integer;
ltype,llength,lspeed,lnote,lmap:string;
x,y:array[1..32]of integer;
public
procedure GETLINE(xindex:integer);
procedure SETLINE;
procedure DELLINE;
published
constructor CREATE;
end;
|