Announcement

Collapse
No announcement yet.

Zeit von einem Server holen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Zeit von einem Server holen

    Hallo Delphi-Entwickler,

    kennt jemand eine Möglichkeit, die Zeit von einem Netzwerk-Server zu holen,
    das muss auch unter Win95/98 funktionieren, also nicht NetRemoteTOD aus der NETAPI32.DLL

    Thomas Stach

  • #2
    Hallo,

    die API-Funktion <b>NetRemoteTOD</b> ist auch unter Windows 9x richtig, allerdings die DLL nicht ;-)

    Unter Windows 9x muss diese Funktion unter dem Export-Namen <b>NetRemoteTODA</b> aus <b>RADMIN32.DLL</b> exportiert werden:
    <pre>
    FillChar(TOD, SizeOf(TOD), 0);
    try
    if (Win32Platform = Ver_PlatForm_Win32_NT) then
    // Zielrechner verwendet Windows NT
    begin
    wErrMode := SetErrorMode(SEM_NOOPENFILEERRORBOX);
    hLibrary := LoadLibrary(NTlib);
    SetErrorMode(wErrMode);
    if hLibrary = 0 then
    raise ENetTODError.Create(cLERROR + NTlib);
    @NTNetRemoteTOD := GetProcAddress(hLibrary, 'NetRemoteTOD');
    @NTNetApiBufferFree := GetProcAddress(hLibrary, 'NetApiBufferFree');
    StringtoWideChar(pChar(TimeServer), @wsSystem, sizeof(wsSystem));
    try
    NetCheck(NTNetRemoteTOD(@wsSystem, pTOD));
    TOD := pTOD^;
    finally
    NetCheck(NTNetApiBufferFree(pTOD));
    end;
    end
    else
    // Zielrechner verwendet Windows 95 mit Radmin32
    begin
    wErrMode := SetErrorMode(SEM_NOOPENFILEERRORBOX);
    hLibrary := LoadLibrary(Win95lib);
    SetErrorMode(wErrMode);
    if hLibrary = 0 then
    raise ENetTODError.Create(cLERROR + Win95lib);
    @NTNetRemoteTODA := GetProcAddress(hLibrary, 'NetRemoteTODA');
    @NTNetApiBufferFree := GetProcAddress(hLibrary, 'NetApiBufferFree');
    try
    NetCheck(NTNetRemoteTODA(pChar(TimeServer), pTOD));
    TOD := pTOD^;
    finally
    NetCheck(NTNetApiBufferFree(pTOD));
    end;
    end;
    finally
    if hLibrary <> 0 then
    FreeLibrary(hLibrary);
    end;
    </pre&gt

    Comment


    • #3
      Hallo Andreas,<br>
      ich habe mit dem Bsp experimentiert, aber da mir der Source<br>
      der NETAPI32 und RADMIN32 fehlt, komme ich mit einigen Dingen<br>
      nicht weiter:<br>
      - wie sind NTNetRemoteTOD,NTNetApiBufferFree definiert?:<br>
      - TimerServer in UNC - //name?<br>
      - wo ist NetCheck definiert?<br>
      - TOD habe ich als Byte definiert, aber der Rückgabewert ist wohl<br>
      ein Typ TIME_OF_DAY_INFO ??<br>
      <br>
      Gruß - Helmut<br&gt

      Comment


      • #4
        Hallo,

        es wird das Verfahren abkürzen, wenn ich das Beispielprojekt (GST2.zip) im <b>Download</b>-Ordner des Delphi-Forums ablege

        Comment


        • #5
          Hallo Andreas,<br>
          <br>
          vielen Dank für das Beispiel-Projekt in GST2.ZIP!<br>
          <br>
          Leider bin ich auch dafür viel zu blöd ...<br>
          Habe es auf einem Win98-Rechner getestet: als erstes bringt Win32Platform<>Ver_PlatForm_Win32_NT<br>
          ==> damit wird versucht, RADMIN32.DLL zu verwenden.<br>
          Im Gegensatz zur NETAPI32.DLL gibt es die aber im Win98 nicht.<br>
          Habe mir auch die Mühe gemacht, alle CAB-Files der Win98-CD nach der RADMIN32.DLL zu durchsuchen: nichts.<br>
          Also habe ich es mit NETAPI32.DLL versucht: das gibt nur Speicher-Adressierungsfehler ohne Ende ...<br>
          Jetzt bin ich auch soweit wie Thomas.<br>
          Gruss - Helmu

          Comment


          • #6
            Hallo,

            für Windows 9x wird RADMIN32.DLL benötigt, daher kann der Versuch mit NETAPI32.DLL nicht zum Erfolg führen. Ich habe jetzt noch einmal auf meinem MSDN-CDROMs nachgeschaut und bin dort auf die folgende Fundstelle gestossen: <b>Microsoft Windows 95 Service Pack 1</b> (<i>Development Platform US DISC 3 Windows 95 versions, Add-ons for Windows 95</i>). Dort gibt es das Unterverzeichnis <b>Tools\Servmgmt</b> und hier finden sich gleich 10 DLLs, darunter RADMIN32.DLL. Der folgende Auszug stammt aus der README.TXT dieses Verzeichnisses:
            <pre>
            Windows NT Server Tools for Windows 95
            -------------------------------------------------
            This document contains information about the Windows NT(TM) Server
            Tools that wasn't available when the "Windows NT Server
            Installation Guide" version 3.5 (also used for Windows NT Server
            version 3.51) was printed.

            Contents
            --------
            1. Installing Windows NT Server Tools
            2. Additional Password Prompts for Windows NT Server Tools
            3. Establishing Trust Relationships With Windows NT Server Tools
            4. Logging on through Windows NT Server Tools
            5. Removing Windows NT Server Tools
            6. Using Windows NT Server Tools
            ----------------------------------------------------

            1. Installing Windows NT Server Tools
            -------------------------------------
            This version of Windows NT Server Tools is for use on computers
            running Windows(TM) 95.

            To install the Server Tools on a computer running Windows 95:

            1. Make sure the boot drive has at least 2.5M free.

            2. Click Start, and then point to Settings.

            3. Click Control Panel.

            4. Double-click Add/Remove Programs.

            5. Select the Windows Setup tab.

            6. Choose the Have Disk button. Specify a directory (local,
            CD-ROM, or network drive) that contains the Windows NT Server
            Tools files (there must be a srvtools.inf file in this
            directory). Choose OK.

            7. Click the box next to the Windows NT Server Tools entry.

            8. Choose the Install button. After all of the files are copied,
            choose OK.

            Windows NT Server Tools are installed in a \srvtools directory
            on the computer's boot drive.

            9. Manually adjust lines in the computer's AUTOEXEC.BAT file to
            include c:\srvtools in the PATH (if c: is the boot drive).
            For example, if the boot drive is c:, append the following to
            the line that starts with "PATH....":

            ;c:\srvtools

            10. Restart the computer for the new path to take effect. (Click
            Start, and then click Shut Down. Select Restart the Computer.
            Click Yes).

            The Windows NT Server Tools are now installed on the Windows 95 computer.
            For more information about using Windows NT Server Tools,
            see "Using Windows NT Server Tools" later in this file.

            ...
            ...
            ...
            </pre&gt

            Comment


            • #7
              Hallo Andreas,<br>
              <br>
              ich habe mir die Win95 Servertools besorgt, bei denen auch die RADMIN32.DLL enthalten ist.<br>
              Die Servertools sind ganz brauchbar und praktisch,<br>
              die Möglichkeit der Abfrage der Serverzeit funktioniert bei Win95-Rechnern jetzt auch!<br>
              <br>
              Vielen Dank für deine Hilfe!!!<br>
              <br>
              Gruß - Helmu

              Comment


              • #8
                Hallo,<br>
                <br>
                da wir nicht be jedem WIN95-Client die ServerTools installieren wollen, haben wir noch untersucht, was die<br>
                Minimal-Bedingungen sind.<br>
                1. Eine Installation der ServerTools ist nicht erforderlich. Ebenso kein separates Verzeichnis und keine Path-Anweisung.<br>
                2. Es reicht aus, die Dateien RADMIN32.DLL und RLOCAL32.DLL z.B. im Anwendungs-Verzeichnis zu haben.<br>
                <br>
                Gruß und nochmals Danke: <br>
                Helmu

                Comment

                Working...
                X