#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    8
    Rep Power
    0

    problem with return vaules help !!


    i get wrong return vaules

    at NetRemoteTOD, in tme_of_day structure

    like
    tod_hours
    Specifies a DWORD value that contains the current hour. Valid values are 0 through 23.

    i get 4194304, at this i dunno why

    here is the code
    http://authors.aspalliance.com/aylar/ViewPasteCode.aspx?PasteCodeID=3490
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    When passing Delphi records to windows functions, you have to declare them "packed" so the compiler doesn't realign the fields.

    i.e. type myRec=packed record ..... end;

    Not sure if this applies here, DWORD should be the default alignment, so a record of DWORDs is already packed. But you should give it a try.

    hth,
    M.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    8
    Rep Power
    0
    same
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4247
    I just looked at the code and boy, it has a big flaw. I'm assuming this is where your problem is:
    Code:
    var Buffer     :pointer;
        Rek        :PTime_Of_Day_Info;
        sex:dword;
    
    begin
    sex:=NetRemoteTOD(nil,buffer);
    if sex = 0 then
       Rek:=PTime_Of_Day_Info(Buffer);
    writeln(rek.tod_elapsedt);
    writeln(rek.tod_msecs);
    writeln(rek.tod_hours);
    .... lots of other fields
    Note the stuff in bold. If the call to NetRemoteToD succeeds, then it executes that line. If not, it doesn't execute that line, so Rek could be pointing anywhere. Regardless of whether the function succeeds or fails, it is writing out data. So, if NetRemoteToD fails, rek is pointing to uninitialized data and hence the data that is written out is completely bogus.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    8
    Rep Power
    0
    yes i noted that once a while after i posted the message, well i still get some wrong vaules and i hae no idiea why. the function seems to work but there are some wrong vaules.

    Code:
    C:\>time 
    The current time is: 0:55:46.21
    Enter the new time:
    thats sample thing in cmd to kow the time.

    Code:
    C:\>time1
    +------------------+
    Currect Time is 15:55:48
    +------------------+
    thats my file it seems to get the mins and sec good but not the nost importent hours

    and thats the finel code: http://www.jinote.com/css/NetRemoteTOD.rar

    P.S: i tut maby the zone time inc / dec the hours but i cant get the zone currect vaule too.

    so what to do ?

IMN logo majestic logo threadwatch logo seochat tools logo