Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 12-28-2003, 06:57 AM
adgj31081980 adgj31081980 is offline
Member
 
Join Date: Feb 2003
Posts: 40
Default For mshkolnik or any other...

Hi mshkolnik!
I have o problem with CompareTime procedure. I wrote the following code using what you told and helped me with:


var F: TextFile;
dataentries: Integer;
J: Integer;
a: string;
b,c,d: string;
hDll : THandle;
NetShareAddWinNT : function(servername : PWideChar;
level : DWORD;
buf : Pointer;
var parm_Err : DWORD)WORD;stdcall;

si2 : share_info_2;
tamano : Short;
res, err : DWORD;
NameNT: PWChar;
i: Integer;
begin
dataentries:=ListBox2.Items.Count-1;
for J:=0 to dataentries do
begin
AssignFile(F,'C:\WINDOWS\'+ListBox2.Items.Strings[dataentries]);
Reset(F);
readln(F,a);
readln(F,c);
readln(F,d);
DateTimePicker3.Time:=StrToTime(a);
if CompareTime(Time,DateTimePicker3.Time)= 1 then
begin
hDll := LoadLibrary('NetApi32.dll');
if hDll > 32 then
begin
NetShareAddWinNT := GetProcAddress(hDll, 'NetShareAdd');
tamano := sizeof(si2);
FillChar(si2, tamano, 0);
readln(F,c);
si2.shi2_netname := StringToOleStr(c);
si2.shi2_type := STYPE_DISKTREE;
si2.shi2_permissions := ACCESS_READ;
si2.shi2_max_uses := 1;
si2.shi2_current_uses := 1;
readln(F,d);
si2.shi2_path:=StringToOleStr(d);
res := NetShareAddWinNT(nil, 2, @si2, err);
FreeLibrary(hDll);
end
else
begin
readln(F,b);
DateTimePicker3.Time:=StrToTime(b);
if CompareTime(Time,DateTimePicker3.Time) = 1 then
begin
hDll := LoadLibrary('NetApi32.dll');
if hDll > 32 then
begin
i := SizeOf(WideChar)*256;
GetMem(NameNT, i); StringToWideChar(ListBox2.Items.Strings[dataentries], NameNT, i);
NetShareDel(nil, NameNT, 0);
FreeMem(NameNT);
end
else
end
end
else
end
end


The problem is as follows: I use DateTimePicker3 just for reference to see if the procedure works and it does I guess till comparing times, because it doesn't add or delete that network share. If you need other details I'll be more than happy to offer.
I can build it, compile it, and run, but it doesn't do what I "told" it to do.
Thanks! I started this project, and thooght that it's easy, and I got my self in more problems than ever before. Sincerely yours, Laurentiu Duca
Reply With Quote
  #2  
Old 12-28-2003, 12:56 PM
mshkolnik mshkolnik is offline
Senior Member
 
Join Date: Jul 2001
Posts: 4,195
Default RE: For mshkolnik or any other...

I'm not sure that I understand your task but try to compare so:

if CompareTime(Time,DateTimePicker3.Time)= EqualsValue then
...

With best regards, Mike Shkolnik
http://www.scalabium.com
Reply With Quote
  #3  
Old 12-28-2003, 11:35 PM
adgj31081980 adgj31081980 is offline
Member
 
Join Date: Feb 2003
Posts: 40
Default RE: For mshkolnik or any other...

The task is as follows...
That procedure is for a TTimer component, for the OnTimer event.
More precise, OnTimer, the computer gets a string from a file, replaces DateTimePicker3.Time with that string, and then compares it with the current computer time (RTC). If the compare returns GreaterThanValue (the computer time is later than DateTimePicker3.Time, it adds a network share loaded from the first file I was talking about). Else, it loads another string from the file, replaces the DateTimePicker3.Time with this value and checks if it is GreaterThanValue with the computer time. If it is then deletes the networks share, and so on, the OnTimer event repeats itself. Thanks for the help and advice. From Romania, sincerely yours, Laurentiu Duca
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 09:10 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.