Results 1 to 3 of 3

Thread: What are the best tags for C++ code?

  1. #1

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    What are the best tags for C++ code?

    How does the PHP tag look?
    PHP Code:
    //HookDemo.cpp
    #include <windows.h>
    #include "WINUSER.H"    
    /*---------------------------------------------
              Shared Variables
    This data is shared between both prcesses.  The
    VB App has access to these variables through the
    function SetSharedData
    ---------------------------------------------*/
    #pragma data_seg(".shared")
        
    bool ChangeMessage false;
        
    int Shared_uMsg 0;
        
    int Shared_wParam 0;
        
    int Shared_lParam 0;
        
    HWND hWndVB 0//handle to subclassed VB Window
        
    HWND hWndCtrl 0;//handle to the window we want to monitor
    #pragma data_seg()
    #pragma comment(linker, "/SECTION:.shared,RWS")

    //---------------------------------------------
    // Global Variables, specific to each process
    //---------------------------------------------
        
    HHOOK    hmsgHooks 0;        // Hook handle for WH_GETMESSAGE
        
    HINSTANCE    hInstance;    // Global instance handle for DLL

    //--------------------------------------------
    //        DLL entry-point 
    //--------------------------------------------
    BOOL WINAPI DllMain(
        
    HINSTANCE hinstDLL,  // handle to DLL module
        
    DWORD fdwReason,     // reason for calling function
        
    LPVOID lpvReserved )  // reserved
    {
        
    // Perform actions based on the reason for calling.
        
    switch( fdwReason 
        { 
            case 
    DLL_PROCESS_ATTACH:
             
    // Initialize once for each new process.
             // Return FALSE to fail DLL load.
                
    hInstance hinstDLL;//save dll handle for each process
                
    break;
        
            case 
    DLL_THREAD_ATTACH:
             
    // Do thread-specific initialization.
                
    break;

            case 
    DLL_THREAD_DETACH:
             
    // Do thread-specific cleanup.
                
    break;

            case 
    DLL_PROCESS_DETACH:
             
    // Perform any necessary cleanup.
                
    break;
        }
        return 
    TRUE;  // Successful DLL_PROCESS_ATTACH.

    Not too bad, I don't like the orange for comments

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: What are the best tags for C++ code?

    You need to grab the Codeguru code highlighter tool Brad has a link in some post somewhere in the Feedback forum.

    Code:
    //HookDemo.cpp
    #include <windows.h>
    #include "WINUSER.H"    
    /*---------------------------------------------
              Shared Variables
    This data is shared between both prcesses.  The
    VB App has access to these variables through the
    function SetSharedData
    ---------------------------------------------*/
    #pragma data_seg(".shared")
        bool ChangeMessage = false;
        int Shared_uMsg = 0;
        int Shared_wParam = 0;
        int Shared_lParam = 0;
        HWND hWndVB = 0; //handle to subclassed VB Window
        HWND hWndCtrl = 0;//handle to the window we want to monitor
    #pragma data_seg()
    #pragma comment(linker, "/SECTION:.shared,RWS")
    
    //---------------------------------------------
    // Global Variables, specific to each process
    //---------------------------------------------
        HHOOK    hmsgHooks = 0;        // Hook handle for WH_GETMESSAGE
        HINSTANCE    hInstance;    // Global instance handle for DLL
    
    //--------------------------------------------
    //        DLL entry-point
    //--------------------------------------------
    BOOL WINAPI DllMain(
        HINSTANCE hinstDLL,  // handle to DLL module
        DWORD fdwReason,     // reason for calling function
        LPVOID lpvReserved )  // reserved
    {
        // Perform actions based on the reason for calling.
        switch( fdwReason )
        {
            case DLL_PROCESS_ATTACH:
             // Initialize once for each new process.
             // Return FALSE to fail DLL load.
                hInstance = hinstDLL;//save dll handle for each process
                break;
        
            case DLL_THREAD_ATTACH:
             // Do thread-specific initialization.
                break;
    
            case DLL_THREAD_DETACH:
             // Do thread-specific cleanup.
                break;
    
            case DLL_PROCESS_DETACH:
             // Perform any necessary cleanup.
                break;
        }
        return TRUE;  // Successful DLL_PROCESS_ATTACH.
    }

  3. #3

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: What are the best tags for C++ code?

    OK, let's see how it works
    Code:
    //HookDemo.cpp
    #include <windows.h>
    #include "WINUSER.H"    
    /*---------------------------------------------
              Shared Variables
    This data is shared between both prcesses.  The
    VB App has access to these variables through the
    function SetSharedData
    ---------------------------------------------*/
    #pragma data_seg(".shared")
        bool ChangeMessage = false;
        int Shared_uMsg = 0;
        int Shared_wParam = 0;
        int Shared_lParam = 0;
        HWND hWndVB = 0; //handle to subclassed VB Window
        HWND hWndCtrl = 0;//handle to the window we want to monitor
    #pragma data_seg()
    #pragma comment(linker, "/SECTION:.shared,RWS")
    
    //---------------------------------------------
    // Global Variables, specific to each process
    //---------------------------------------------
        HHOOK    hmsgHooks = 0;        // Hook handle for WH_GETMESSAGE
        HINSTANCE    hInstance;    // Global instance handle for DLL
    
    //--------------------------------------------
    //        DLL entry-point
    //--------------------------------------------
    BOOL WINAPI DllMain(
        HINSTANCE hinstDLL,  // handle to DLL module
        DWORD fdwReason,     // reason for calling function
        LPVOID lpvReserved )  // reserved
    {
        // Perform actions based on the reason for calling.
        switch( fdwReason )
        {
            case DLL_PROCESS_ATTACH:
             // Initialize once for each new process.
             // Return FALSE to fail DLL load.
                hInstance = hinstDLL;//save dll handle for each process
                break;
        
            case DLL_THREAD_ATTACH:
             // Do thread-specific initialization.
                break;
    
            case DLL_THREAD_DETACH:
             // Do thread-specific cleanup.
                break;
    
            case DLL_PROCESS_DETACH:
             // Perform any necessary cleanup.
                break;
        }
        return TRUE;  // Successful DLL_PROCESS_ATTACH.
    }
    Pretty cool, thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width