Výsledky 1 až 8 z 8

Téma: C++ --> Delphi

  1. #1

    Standardní C++ --> Delphi

    Potřeboval bych tento zroják předělat na takový, který by šel zkompilovat v Delphi a správně fungoval.

    /************************************************** ****************************
    *
    * Cacheset - Cache working set controller
    *
    * Copyright (c) 1997 Mark Russinovich
    * http://www.ntinternals.com
    *
    * PROGRAM: Cacheset.c
    *
    ************************************************** ****************************/
    #include <windows.h>
    #include <stdio.h>
    #include <process.h>
    #include <commctrl.h>
    #include <winioctl.h>
    #include "resource.h"

    //
    // System cache information class
    //
    #define SYSTEMCACHEINFORMATION 0x15

    //
    // Used to get cache information
    //
    typedef struct {
    ULONG CurrentSize;
    ULONG PeakSize;
    ULONG PageFaultCount;
    ULONG MinimumWorkingSet;
    ULONG MaximumWorkingSet;
    ULONG Unused[4];
    } SYSTEM_CACHE_INFORMATION;

    //
    // Calls to get and set the information
    //
    ULONG (__stdcall *NtQuerySystemInformation)(
    ULONG SystemInformationClass,
    PVOID SystemInformation,
    ULONG SystemInformationLength,
    PULONG ReturnLength
    );

    ULONG (__stdcall *NtSetSystemInformation)(
    ULONG SystemInformationClass,
    PVOID SystemInformation,
    ULONG SystemInformationLength
    );

    //
    // instance
    //
    HINSTANCE hInst;

    //
    // main window
    //
    HWND hMainDlg;

    //
    // General buffer for storing temporary strings
    //
    static TCHAR msgbuf[ 257 ];

    //
    // original cache settings
    //
    SYSTEM_CACHE_INFORMATION ResetCache;

    //
    // forward define
    //
    void Abort( HWND hWnd, char * Msg );

    //----------------------------------------------------------------------
    //
    // CenterWindow
    //
    // Centers the Window on the screen.
    //
    //----------------------------------------------------------------------
    VOID CenterWindow( HWND hDlg )
    {
    RECT aRt;

    // center the dialog box
    GetWindowRect( hDlg, &aRt );
    OffsetRect( &aRt, -aRt.left, -aRt.top );
    MoveWindow( hDlg,
    ((GetSystemMetrics( SM_CXSCREEN ) -
    aRt.right ) / 2 + 4) & ~7,
    (GetSystemMetrics( SM_CYSCREEN ) -
    aRt.bottom) / 2,
    aRt.right, aRt.bottom, 0 );
    }


    //----------------------------------------------------------------------
    //
    // SetPrivilege
    //
    // Adjusts the token privileges.
    //
    //----------------------------------------------------------------------
    BOOL SetPrivilege( HANDLE hToken, LPCTSTR Privilege, BOOL bEnablePrivilege )
    {
    TOKEN_PRIVILEGES tp;
    LUID luid;
    TOKEN_PRIVILEGES tpPrevious;
    DWORD cbPrevious=sizeof(TOKEN_PRIVILEGES);

    if(!LookupPrivilegeValue( NULL, Privilege, &luid )) return FALSE;

    //
    // first pass. get current privilege setting
    //
    tp.PrivilegeCount = 1;
    tp.Privileges[0].Luid = luid;
    tp.Privileges[0].Attributes = 0;

    AdjustTokenPrivileges(
    hToken,
    FALSE,
    &tp,
    sizeof(TOKEN_PRIVILEGES),
    &tpPrevious,
    &cbPrevious
    );

    if (GetLastError() != ERROR_SUCCESS) return FALSE;

    //
    // second pass. set privilege based on previous setting
    //
    tpPrevious.PrivilegeCount = 1;
    tpPrevious.Privileges[0].Luid = luid;

    if(bEnablePrivilege) {
    tpPrevious.Privileges[0].Attributes |= (SE_PRIVILEGE_ENABLED);
    }
    else {
    tpPrevious.Privileges[0].Attributes ^= (SE_PRIVILEGE_ENABLED &
    tpPrevious.Privileges[0].Attributes);
    }

    AdjustTokenPrivileges(
    hToken,
    FALSE,
    &tpPrevious,
    cbPrevious,
    NULL,
    NULL
    );

    if (GetLastError() != ERROR_SUCCESS) return FALSE;

    return TRUE;
    }


    //----------------------------------------------------------------------
    //
    // Abort
    //
    // If there is a fatal problem, pop up a message box and die. Assumes
    // that it is called from the dialog box.
    //
    //----------------------------------------------------------------------
    void Abort( HWND hWnd, char * Msg )
    {
    MessageBox( hWnd, Msg, "Cacheset", MB_ICONERROR|MB_OK );
    if( hWnd ) EndDialog( hWnd, 1 );
    PostQuitMessage( 1 );
    }


    //----------------------------------------------------------------------
    //
    // MainDialog
    //
    // This is the main window.
    //
    //----------------------------------------------------------------------
    LONG APIENTRY MainDialog( HWND hDlg, UINT message, UINT wParam,
    LONG lParam ) {
    TCHAR text[16];
    SYSTEM_CACHE_INFORMATION newCacheSize;
    ULONG returnLength;

    switch (message) {
    case WM_INITDIALOG :

    // center the window
    CenterWindow( hDlg );

    // get the current settings from the driver
    if( NtQuerySystemInformation( SYSTEMCACHEINFORMATION,
    &ResetCache, sizeof(ResetCache),
    &returnLength ) ) {
    MessageBox( hDlg, TEXT("Could not obtain cache settings"), "Cacheset", MB_ICONWARNING|MB_OK );
    return 0;
    }

    wsprintf( text, TEXT("%d"), ResetCache.MinimumWorkingSet *4 );
    SetDlgItemText( hDlg, IDC_MINIMUM, text );
    wsprintf( text, TEXT("%d"), ResetCache.MaximumWorkingSet *4 );
    SetDlgItemText( hDlg, IDC_MAXIMUM, text );

    wsprintf( text, TEXT("%d KB"), ResetCache.CurrentSize / 1024);
    SetDlgItemText( hDlg, IDC_CURRENT, text );
    wsprintf( text, TEXT("%d KB"), ResetCache.PeakSize / 1024 );
    SetDlgItemText( hDlg, IDC_PEAK, text );


    // Start up timer to periodically update screen
    SetTimer( hDlg, 1, 500/*ms*/, NULL );
    return 0;

    case WM_COMMAND:
    switch (LOWORD( wParam )) {

    case IDDEFAULT:

    newCacheSize.MinimumWorkingSet = 4* ResetCache.MinimumWorkingSet * 1024;
    newCacheSize.MaximumWorkingSet = 4* ResetCache.MaximumWorkingSet * 1024;
    if( NtSetSystemInformation( SYSTEMCACHEINFORMATION,
    &newCacheSize, sizeof( newCacheSize)) ) {

    MessageBox( hDlg, TEXT("Default settings were out of valid ranges"), "Cacheset", MB_ICONWARNING|MB_OK );
    return 0;
    }

    // get the current settings from the driver
    if( NtQuerySystemInformation( SYSTEMCACHEINFORMATION,
    &newCacheSize, sizeof(newCacheSize),
    &returnLength ) ) {
    MessageBox( hDlg, TEXT("Could not obtain cache settings"), "Cacheset", MB_ICONWARNING|MB_OK );
    return 0;
    }

    wsprintf( text, TEXT("%d"), newCacheSize.MinimumWorkingSet *4 );
    SetDlgItemText( hDlg, IDC_MINIMUM, text );
    wsprintf( text, TEXT("%d"), newCacheSize.MaximumWorkingSet *4 );
    SetDlgItemText( hDlg, IDC_MAXIMUM, text );

    wsprintf( text, TEXT("%d KB"), newCacheSize.CurrentSize / 1024);
    SetDlgItemText( hDlg, IDC_CURRENT, text );
    wsprintf( text, TEXT("%d KB"), newCacheSize.PeakSize / 1024 );
    SetDlgItemText( hDlg, IDC_PEAK, text );

    MessageBox( hDlg, TEXT("Previous cache settings applied"), "Cacheset", MB_ICONINFORMATION|MB_OK );
    break;

    case IDCLEAR:

    // clear the cache working set
    newCacheSize.MinimumWorkingSet = (ULONG) -1;
    newCacheSize.MaximumWorkingSet = (ULONG) -1;
    if( NtSetSystemInformation( SYSTEMCACHEINFORMATION,
    &newCacheSize, sizeof( newCacheSize)) ) {

    MessageBox( hDlg, TEXT("Cache clear settings were out of valid ranges"), "Cacheset", MB_ICONWARNING|MB_OK );
    return 0;
    }

    // get the current settings from the driver
    if( NtQuerySystemInformation( SYSTEMCACHEINFORMATION,
    &newCacheSize, sizeof(newCacheSize),
    &returnLength ) ) {
    MessageBox( hDlg, TEXT("Could not obtain cache settings"), "Cacheset", MB_ICONWARNING|MB_OK );
    return 0;
    }

    wsprintf( text, TEXT("%d"), newCacheSize.MinimumWorkingSet *4 );
    SetDlgItemText( hDlg, IDC_MINIMUM, text );
    wsprintf( text, TEXT("%d"), newCacheSize.MaximumWorkingSet *4 );
    SetDlgItemText( hDlg, IDC_MAXIMUM, text );

    wsprintf( text, TEXT("%d KB"), newCacheSize.CurrentSize / 1024);
    SetDlgItemText( hDlg, IDC_CURRENT, text );
    wsprintf( text, TEXT("%d KB"), newCacheSize.PeakSize / 1024 );
    SetDlgItemText( hDlg, IDC_PEAK, text );

    MessageBox( hDlg, TEXT("Cache working set cleared"), "Cacheset", MB_ICONINFORMATION|MB_OK );
    break;

    case IDAPPLY:

    GetDlgItemText( hDlg, IDC_MINIMUM, text, 16 );
    newCacheSize.MinimumWorkingSet = atoi( text ) * 1024;
    GetDlgItemText( hDlg, IDC_MAXIMUM, text, 16 );
    newCacheSize.MaximumWorkingSet = atoi( text ) * 1024;

    if( NtSetSystemInformation( SYSTEMCACHEINFORMATION,
    &newCacheSize, sizeof( newCacheSize)) ) {

    MessageBox( hDlg, TEXT("New settings were out of valid ranges"), "Cacheset", MB_ICONWARNING|MB_OK );
    return 0;
    }

    // get the current settings from the driver
    if( NtQuerySystemInformation( SYSTEMCACHEINFORMATION,
    &newCacheSize, sizeof(newCacheSize),
    &returnLength ) ) {

    MessageBox( hDlg, TEXT("Could not obtain cache settings"), "Cacheset", MB_ICONWARNING|MB_OK );
    return 0;
    }

    wsprintf( text, TEXT("%d"), newCacheSize.MinimumWorkingSet *4 );
    SetDlgItemText( hDlg, IDC_MINIMUM, text );
    wsprintf( text, TEXT("%d"), newCacheSize.MaximumWorkingSet *4 );
    SetDlgItemText( hDlg, IDC_MAXIMUM, text );

    wsprintf( text, TEXT("%d KB"), newCacheSize.CurrentSize / 1024);
    SetDlgItemText( hDlg, IDC_CURRENT, text );
    wsprintf( text, TEXT("%d KB"), newCacheSize.PeakSize / 1024 );
    SetDlgItemText( hDlg, IDC_PEAK, text );

    MessageBox( hDlg, TEXT("New cache settings applied"), "Cacheset", MB_ICONINFORMATION|MB_OK );
    break;

    case IDCANCEL:
    EndDialog (hDlg, 0) ;
    PostQuitMessage (0) ;
    break ;
    }
    break;

    case WM_TIMER:

    // get the current settings
    if( NtQuerySystemInformation( SYSTEMCACHEINFORMATION,
    &newCacheSize, sizeof(newCacheSize),
    &returnLength ) ) {
    MessageBox( hDlg, TEXT("Could not obtain cache settings"), "Cacheset", MB_ICONWARNING|MB_OK );
    return 0;
    }

    wsprintf( text, TEXT("%d KB"), newCacheSize.CurrentSize / 1024);
    SetDlgItemText( hDlg, IDC_CURRENT, text );
    wsprintf( text, TEXT("%d KB"), newCacheSize.PeakSize / 1024 );
    SetDlgItemText( hDlg, IDC_PEAK, text );
    break;


    case WM_CLOSE:
    EndDialog (hDlg, 0);
    PostQuitMessage( 0 );
    break;
    }
    return DefWindowProc ( hDlg, message, wParam, lParam);
    }


    //--------------------------------------------------------------------
    //
    // LocateNDLLCalls
    //
    // Loads function entry points in NTDLL
    //
    //--------------------------------------------------------------------
    BOOLEAN LocateNTDLLCalls()
    {

    if( !(NtQuerySystemInformation = (void *) GetProcAddress( GetModuleHandle("ntdll.dll"),
    "NtQuerySystemInformation" )) ) {

    return FALSE;
    }

    if( !(NtSetSystemInformation = (void *) GetProcAddress( GetModuleHandle("ntdll.dll"),
    "NtSetSystemInformation" )) ) {

    return FALSE;
    }
    return TRUE;
    }


    //----------------------------------------------------------------------
    //
    // DummyProc
    //
    // This is the Wnd proc for a dummy window we use as the parent
    // to our real window. This makes it so that we don't get a stupid
    // icon on the task bar!
    //
    //----------------------------------------------------------------------
    LONG APIENTRY DummyProc( HWND hDlg, UINT message, UINT wParam,
    LONG lParam ) {

    if( message == WM_CREATE || message == WM_DESTROY )
    return 0;
    else
    return DefWindowProc ( hDlg, message, wParam, lParam);
    }


    //----------------------------------------------------------------------
    //
    // WinMain
    //
    // Registers a class. The reason I did this is because the application
    // doesn't get cleaned up properly upon exit if winmain just calls
    // dialogbox. This was manifested by all the system icons disappearing
    // after the program exited. See Petzold's hexcalc example for the base
    // of this.
    //
    //----------------------------------------------------------------------
    int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow )
    {
    static TCHAR szAppName [] = TEXT("CACHESET") ;
    MSG msg ;
    WNDCLASSEX wndclass ;
    HWND hDummyWnd;
    int NTVersion;
    int len = 256;
    HANDLE hToken;
    SYSTEM_CACHE_INFORMATION newCacheSize;
    ULONG minSize, maxSize;

    // save instance
    hInst = hInstance;

    // init common controls
    InitCommonControls();

    // get NT version
    NTVersion = GetVersion();
    if( NTVersion >= 0x80000000 ) {
    Abort( NULL, TEXT("Not running on Windows NT"));
    return TRUE;
    }

    // Enable increase quota privilege
    if(!OpenProcessToken( GetCurrentProcess(),
    TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
    &hToken )) {

    printf("You do not have the necessary privilege to run this program\n");
    return -1;
    }

    // Enable SeDebugPrivilege
    if(!SetPrivilege(hToken, SE_INCREASE_QUOTA_NAME, TRUE))
    {

    Abort(NULL, TEXT("You must have the INCREASE_QUOTA privilege to run CacheSet"));
    CloseHandle(hToken);
    return -1;
    }
    CloseHandle( hToken );

    // locate the calls we need in NTDLL
    LocateNTDLLCalls();

    // If there are command line arguments, set the cache size
    if( lpCmdLine && (sscanf( lpCmdLine," %d %d", &minSize, &maxSize ) == 2) ) {

    // set the cache size
    newCacheSize.MinimumWorkingSet = minSize * 1024;
    newCacheSize.MaximumWorkingSet = maxSize * 1024;
    NtSetSystemInformation( SYSTEMCACHEINFORMATION,
    &newCacheSize, sizeof(newCacheSize) );
    return 0;
    }

    // create a dummy class and window that will hide the task tray icon for us
    wndclass.cbSize = sizeof( WNDCLASSEX );
    wndclass.style = 0 ;
    wndclass.lpfnWndProc = (WNDPROC) DummyProc ;
    wndclass.cbClsExtra = 0 ;
    wndclass.cbWndExtra = 0 ;
    wndclass.hInstance = hInstance ;
    wndclass.hIcon = LoadIcon (hInstance, "APPICON") ;
    wndclass.hIconSm = LoadIcon (hInstance, "APPICON");
    wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
    wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE+1);
    wndclass.lpszMenuName = NULL ;
    wndclass.lpszClassName = "Dummy" ;
    RegisterClassEx (&wndclass) ;

    hDummyWnd = CreateWindowEx( WS_EX_TOOLWINDOW, "Dummy", "",
    0, -1, -1, 0, 0, 0, 0, hInstance, 0 );

    // create the main window class
    wndclass.cbSize = sizeof( WNDCLASSEX );
    wndclass.style = CS_HREDRAW | CS_VREDRAW ;
    wndclass.lpfnWndProc = (WNDPROC) MainDialog ;
    wndclass.cbClsExtra = 0 ;
    wndclass.cbWndExtra = DLGWINDOWEXTRA ;
    wndclass.hInstance = hInstance ;
    wndclass.hIcon = LoadIcon (hInstance, "APPICON") ;
    wndclass.hIconSm = LoadIcon (hInstance, "APPICON");
    wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
    wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE+1);
    wndclass.lpszMenuName = NULL ;
    wndclass.lpszClassName = szAppName ;
    RegisterClassEx (&wndclass) ;

    // create the dialog
    hMainDlg = CreateDialog( hInstance, "CACHESET", hDummyWnd, (DLGPROC)MainDialog) ;
    ShowWindow( hMainDlg, nCmdShow) ;

    while (GetMessage (&msg, NULL, 0, 0)) {
    if( !IsDialogMessage( hMainDlg, &msg )) {
    TranslateMessage (&msg) ;
    DispatchMessage (&msg) ;
    }
    }
    return msg.wParam ;
    }


    Předem děkuji )
    EC5410 + Chill 400w, AMD Athlon XP 2500+@3200+, AC Copper Silent 2 (rev2), Out: AC Fan Pro TC, DFI NFII Ultra-AL nForce2 Ultra 400, 2x256MB+512MB DDR 333 CL2.5 Dual Channel, inno3D GeForce4 Ti4200-8x 128MB + AC Fan Pro TC, Seagate ST3160023A 160GB, Seagate ST360021A 60GB, Teac CD-W552E, LG SuperMulti GSA-4160B, SB Live! 5.1 Player + Audigy MOD, Windows XP Pro SP2, Karneval TURBO 2000/300

  2. #2

    Standardní

    To ti nikto robit nebude...
    1: Asus P2B 1.10 • Celeron 1100@1364/1.8V • 512MB SDRAM • Samsung SP1213N+WD AC28400 • Toshiba XM-6402B+SD-M1212 • PowerColor AR2L Radeon 9100 64MB • 3C900-Combo • Bt848A • ASB-3940UA • AWE-64 • DTK PTP-3007 • VisionMaster 405 • Umax UC630 • Star LC24-200 Colour 2: PCPartner TXB820DS • Cyrix MII PR300/1.8V • 256MB SDRAM • 2xSamsung HD400LD+IT8212F • Accesstek CW4001 • LS-120 • Mystique 4MB • Millennium II 4MB • 3C509 • CMI8329A+Dream MIDI • ADI ProVista E44 • SyncMaster 203B Notebook: DTK FortisPro TOP-5A • P166MMX/1.8V • 80MB EDO • Hitachi 5K80 40GB • 12,1" TFT Router: A-Trend ATC-1425B • i486DX 50@33/5V • 48MB FPM • WD AC14300 • UMC UM9003F • HP PC LAN 16/TP+ Car: Mazda 323P BA • Z5 1489ccm, 65kW@5500rpm, 134Nm@4000rpm

  3. #3

    Standardní

    Taky sem si myslel, mě by ale stačilo, přepsat tu funkci NtQuerySystemInformation a NtSetSystemInformation. Já to zkoušel podle pár návodů z netu, zkompilovat to šlo, vypadlo to skoro stejně, ale házelo to uplně jiný hodnoty.
    EC5410 + Chill 400w, AMD Athlon XP 2500+@3200+, AC Copper Silent 2 (rev2), Out: AC Fan Pro TC, DFI NFII Ultra-AL nForce2 Ultra 400, 2x256MB+512MB DDR 333 CL2.5 Dual Channel, inno3D GeForce4 Ti4200-8x 128MB + AC Fan Pro TC, Seagate ST3160023A 160GB, Seagate ST360021A 60GB, Teac CD-W552E, LG SuperMulti GSA-4160B, SB Live! 5.1 Player + Audigy MOD, Windows XP Pro SP2, Karneval TURBO 2000/300

  4. #4
    Kluk k sežrání Avatar uživatele xvojta
    Založen
    07.10.2002
    Bydliště
    Velká Morava (Brno)
    Věk
    41
    Příspěvky
    427
    Vliv
    273

    Standardní

    Citace Původně odeslal Rainbow
    To ti nikto robit nebude...
    no zadarmo urcite ne...
    Surface 3 Pro + Nokia Lumia 930 + Volvo V60 D5 + Ford Capri '79 2.3V6 project = mobilní
    ...omnia mea meacum porto...
    WS: ...i5@3,3GHz...16GBram...4TBwd... ATI Rad HD 6870 1GB

  5. #5
    Kluk k sežrání Avatar uživatele xvojta
    Založen
    07.10.2002
    Bydliště
    Velká Morava (Brno)
    Věk
    41
    Příspěvky
    427
    Vliv
    273

    Standardní

    a na co to potrebujes?

    ukol/projekt?

    edit:
    protoze malokdo, kdo ma zdrojak v C++ chce ho prevadet do Delphi.... to je zhuverilost....nehlede na to ze ten zdrojak nevypada jako tvuj... priste umaz ty copyrighty....

    ja bych Te tipnul na clovicka z VUT-FIT.... tam se ted ve velky propaguje Delphi a s Kreslíkovou...
    Surface 3 Pro + Nokia Lumia 930 + Volvo V60 D5 + Ford Capri '79 2.3V6 project = mobilní
    ...omnia mea meacum porto...
    WS: ...i5@3,3GHz...16GBram...4TBwd... ATI Rad HD 6870 1GB

  6. #6

    Standardní

    No, nejsou moje. Ten program je ale volně dostupný i se zdrojákem a já potřebuju vědět, jak ovládat ty dvě fukce, páč si to chci zabudovat do svýho programu. Už jsem věděl dřív, že to jde takhle nastavit, ale až u tohodle programu jsem zjistil jak, ale v Delphi to bohužel nefunguje
    EC5410 + Chill 400w, AMD Athlon XP 2500+@3200+, AC Copper Silent 2 (rev2), Out: AC Fan Pro TC, DFI NFII Ultra-AL nForce2 Ultra 400, 2x256MB+512MB DDR 333 CL2.5 Dual Channel, inno3D GeForce4 Ti4200-8x 128MB + AC Fan Pro TC, Seagate ST3160023A 160GB, Seagate ST360021A 60GB, Teac CD-W552E, LG SuperMulti GSA-4160B, SB Live! 5.1 Player + Audigy MOD, Windows XP Pro SP2, Karneval TURBO 2000/300

  7. #7
    Kluk k sežrání Avatar uživatele xvojta
    Založen
    07.10.2002
    Bydliště
    Velká Morava (Brno)
    Věk
    41
    Příspěvky
    427
    Vliv
    273

    Standardní

    Citace Původně odeslal Big Muscle
    No, nejsou moje. Ten program je ale volně dostupný i se zdrojákem a já potřebuju vědět, jak ovládat ty dvě fukce, páč si to chci zabudovat do svýho programu. Už jsem věděl dřív, že to jde takhle nastavit, ale až u tohodle programu jsem zjistil jak, ale v Delphi to bohužel nefunguje
    to stale neresi otazku, proc Delphi? vzdyt oproti C++ tam neni zadna vyhoda...
    Surface 3 Pro + Nokia Lumia 930 + Volvo V60 D5 + Ford Capri '79 2.3V6 project = mobilní
    ...omnia mea meacum porto...
    WS: ...i5@3,3GHz...16GBram...4TBwd... ATI Rad HD 6870 1GB

  8. #8

    Standardní

    Pokud potřebuješ nějaké služby z NT securities nebo NT shellservices podívej se na sourceforge.net. Jsou tam toho hromady. Podívej se na systémové rutiny uvolněné např po pádu TurboPower. Podívej se na nějaké dobré archivy Delphi, většina rutin je už většinou převedena do syntaxe ObjectPascalu (asi bych začal na www.torry.net ). Podle názvu bych si tipnul že to jsou nějaké nedokumentované ale interfaceované funkce z Win32 (seznam běžících procesů pod NT ?) tak zkus taky http://www.google.com/search?q=NtQue...at+Googlem&lr= . Určitě něco najdeš viz třeba tento callback (je to pořád ještě pascal )

    type
    IO_COUNTERS = record
    ReadOperationCount:Int64;
    WriteOperationCount:Int64;
    OtherOperationCount:Int64;
    ReadTransferCount:Int64;
    WriteTransferCount:Int64;
    OtherTransferCount:Int64;
    end;
    VM_COUNTERS = record
    PeakVirtualSize:ULONG;
    VirtualSize:ULONG;
    PageFaultCount:ULONG;
    PeakWorkingSetSize:ULONG;
    WorkingSetSize:ULONG;
    QuotaPeakedPagedPoolUsage:ULONG;
    QuotaPagedPoolUsage:ULONG;
    QuotaPeakNonPagedPoolUsage:ULONG;
    QuotaNonPagedPoolUsage:ULONG;
    PagefileUsage:ULONG;
    PeakPagefileUsage:ULONG;
    end;

    PSYSTEM_PROCESS = ^SYSTEM_PROCESS;
    SYSTEM_PROCESS = record
    NextEntryDelta:ULONG;
    ThreadCount:ULONG;
    Reserved:array[0..5] of ULONG;

    CreateTime:LARGE_INTEGER;
    UserTime:LARGE_INTEGER;
    KernelTime:LARGE_INTEGER;

    ProcessName:PWideChar;

    BasePriorityWORD;
    ProcessID:ULONG;
    InheritedFromProcessID:ULONG;
    HandleCount:ULONG;
    Reserved2:array[0..1] of ULONG;
    VmCounters:VM_COUNTERS;
    IoCounters:IO_COUNTERS;
    Threads:Pointer;
    end;

    function NtQuerySystemInformationCallback(
    SystemInformationClassWORD;
    SystemInformation:Pointer;
    SystemInformationLength:ULONG;
    ReturnLength:PULONG):ULONG;
    var
    iChanged:Integer;
    pCurrent, pLast:PSYSTEM_PROCESS;
    begin
    result :=
    NtQuerySystemInformationNextHook(
    SystemInformationClass,
    SystemInformation,
    SystemInformationLength,
    ReturnLength);
    if (result <> 0) then
    exit;
    if (SystemInformationClass <> 5) then
    exit;
    pCurrent := PSYSTEM_PROCESS(SystemInformation);
    pLast := nil;

    while (pCurrent <> nil) do
    begin
    if (WideCharToString(pCurrent.ProcessName) = 'myprocess.exe') then
    begin
    inc(iChanged);
    if (pLast <> nil) then
    begin

    if (pCurrent.NextEntryDelta <> 0) then
    begin
    inc(pLast.NextEntryDelta, pCurrent.NextEntryDelta);
    end //NextEntryDelta <> 0
    else
    begin
    pLast.NextEntryDelta := 0;
    end //NextEntryDelta = 0
    end //pLast <> nil
    else
    begin
    if (pCurrent.NextEntryDelta <> 0) then
    begin
    SystemInformation := Pointer(DWORD(SystemInformation) + pCurrent.NextEntryDelta);
    end
    else
    begin
    SystemInformation := nil;
    end;
    end; //pLast = nil
    end; //found our proc
    if (iChanged = 0) then
    begin
    pLast := pCurrent;
    end;

    if (pCurrent.NextEntryDelta <> 0) then
    begin
    pCurrent := PSYSTEM_PROCESS(
    Pointer(
    DWORD(pCurrent) + pCurrent.NextEntryDelta));
    end
    else
    pCurrent := nil;
    end;
    end;
    Jaro

Informace o tématu

Users Browsing this Thread

Toto téma si právě prohlíží 1 uživatelů. (0 registrovaných a 1 anonymních)

Podobná témata

  1. iNET -> WinXP -> Win98
    Založil Fraj#r v sekci fóra Sítě
    Odpovědí: 23
    Poslední příspěvek: 28.01.2008, 19:30
  2. Reklamace repro -> jiný typ -> najde se řešení?
    Založil Brogg v sekci fóra Reklamace a §
    Odpovědí: 7
    Poslední příspěvek: 28.12.2005, 13:37
  3. Delphi : komunikace pres RS-232
    Založil mudboy v sekci fóra Programování
    Odpovědí: 10
    Poslední příspěvek: 07.06.2005, 21:37
  4. delphi 7 X delphi 8
    Založil night_ v sekci fóra Programování
    Odpovědí: 28
    Poslední příspěvek: 25.10.2004, 15:20
  5. Wifi -> HUB -> 2PC - poradte
    Založil Katalyzator v sekci fóra Sítě
    Odpovědí: 2
    Poslední příspěvek: 10.05.2004, 22:31

Pravidla přispívání

  • Nemůžete zakládat nová témata
  • Nemůžete zasílat odpovědi
  • Nemůžete přikládat přílohy
  • Nemůžete upravovat své příspěvky
  •