GetOSProductS

GetOSProductS

Podaje wersję systemu Windows. Zwracane wersje to:
sgsi_x86.dll
  • Windows Server 2008
  • Windows Vista
  • Windows Server 2003
  • Windows XP
  • Windows 2000
  • Windows NT 4.0
  • Unknown Windows NT
  • Windows Millennium Edition
  • Windows 98
  • Windows 95
  • Unknown Windows 9x
sgsi_x64.dll
  • Windows Server 2008
  • Windows Vista
  • Windows Server 2003
  • Windows XP
  • Unknown Windows NT
char* GetOSProductS()

Zwracana wartość:
Wersja systemu.

Przykładowy kod

C++
#include "stdafx.h"
#include <windows.h>

typedef char* (__stdcall *GetOSProductS());
VOID main()
{
        HINSTANCE HLib = NULL
        GetOSProductS FAdr;      

        HLib =LoadLibrary(_T("sgsi_x86.dll"));
        if (HLib != 0)
        {
                FAdr = (GetOSProductS)GetProcAddress(HLib,"GetOSProductS");
                if (NULL !=FAdr)
                        {
                                printf((FAdr)());
                                printf("pn");
                        }
                FreeLibrary(HLib);
        }
        else
    printf("Error. Library not loaded!\n");
        system("pause");
}
C#
using System;
using System.Text;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
    class Program
    {
        [DllImport("sgsi_x86.dll", EntryPoint = "GetOSProductS", CharSet = CharSet.Ansi,
        CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr GetOSProductS();

        /* x64
        [DllImport("sgsi_x64.dll", EntryPoint = "GetOSProductS", CharSet = CharSet.Ansi,
        CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr GetOSProductS();
        */


        static void Main(string[] args)
        {
            Console.WriteLine(Marshal.PtrToStringAnsi(GetOSProductS()));
            Console.ReadKey();
        }
    }
}
Delphi/FPC/Lazarus
program Lib_Test;

{$APPTYPE CONSOLE}

uses
  SysUtils;

function GetOSProductS: Pchar ;StdCall; external 'sgsi_x86.dll' name 'GetOSProductS';
// x64
// function GetOSProductS: Pchar ;StdCall; external 'sgsi_x64.dll' name 'GetOSProductS';


begin
  Writeln(GetOSProductS());
  Readln;
end.
VB .Net
Imports System.Runtime.InteropServices
Imports System.Text

Module Module1

    <DllImport("sgsi_x86.dll", EntryPoint:="GetOSProductS", CharSet:=CharSet.Ansi _
    , CallingConvention:=CallingConvention.StdCall)> _
    Public Function GetOSProductS() As IntPtr
    End Function

    ' <DllImport("sgsi_x64.dll", EntryPoint:="GetOSProductS", CharSet:=CharSet.Ansi _
    ' , CallingConvention:=CallingConvention.StdCall)> _
    ' Public Function GetOSProductS() As IntPtr
    ' End Function

    Sub Main()
        Console.WriteLine(Marshal.PtrToStringAnsi(GetOSProductS()))
        Console.ReadKey()
    End Sub

End Module