Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Convert C++/CLI code to Visual Studio 2002 Managed C++

Convert C++/CLI code to Visual Studio 2002 Managed C++

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++visual-studiohelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goncri
    wrote on last edited by
    #1

    Can I help to convert the next C++/CLI code to Visual Studio 2002 Managed C++?

    bool IsPrinterOk(String ^printerName)
    {
    bool bResult=false;
    HANDLE hPrinter;

    IntPtr pPrinterName=Marshal::StringToHGlobalUni(printerName);
    WCHAR \*pChar=(WCHAR \*)pPrinterName.ToPointer();
    
    if(::OpenPrinter(pChar,&hPrinter,NULL)==0)
        return false;
    
    DWORD bytesNeeded;
    ::GetPrinter(hPrinter,2,0,0,&bytesNeeded);
    PRINTER\_INFO\_2 \*pf=(PRINTER\_INFO\_2 \*)GlobalAlloc(GPTR,bytesNeeded);
    
    if(::GetPrinter(hPrinter,2,(LPBYTE)pf,bytesNeeded,&bytesNeeded)!=0)
        if(pf->cJobs==0 && pf->Status==0)
            bResult=true;
    
    GlobalFree(pf);
    
    ClosePrinter(hPrinter);
    
    return bResult;
    

    }

    What changes must be made in the code? Thanks.

    L D 2 Replies Last reply
    0
    • G goncri

      Can I help to convert the next C++/CLI code to Visual Studio 2002 Managed C++?

      bool IsPrinterOk(String ^printerName)
      {
      bool bResult=false;
      HANDLE hPrinter;

      IntPtr pPrinterName=Marshal::StringToHGlobalUni(printerName);
      WCHAR \*pChar=(WCHAR \*)pPrinterName.ToPointer();
      
      if(::OpenPrinter(pChar,&hPrinter,NULL)==0)
          return false;
      
      DWORD bytesNeeded;
      ::GetPrinter(hPrinter,2,0,0,&bytesNeeded);
      PRINTER\_INFO\_2 \*pf=(PRINTER\_INFO\_2 \*)GlobalAlloc(GPTR,bytesNeeded);
      
      if(::GetPrinter(hPrinter,2,(LPBYTE)pf,bytesNeeded,&bytesNeeded)!=0)
          if(pf->cJobs==0 && pf->Status==0)
              bResult=true;
      
      GlobalFree(pf);
      
      ClosePrinter(hPrinter);
      
      return bResult;
      

      }

      What changes must be made in the code? Thanks.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      goncri wrote:

      What changes must be made in the code?

      Try compiling it and see what errors or warnings you receive.

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      1 Reply Last reply
      0
      • G goncri

        Can I help to convert the next C++/CLI code to Visual Studio 2002 Managed C++?

        bool IsPrinterOk(String ^printerName)
        {
        bool bResult=false;
        HANDLE hPrinter;

        IntPtr pPrinterName=Marshal::StringToHGlobalUni(printerName);
        WCHAR \*pChar=(WCHAR \*)pPrinterName.ToPointer();
        
        if(::OpenPrinter(pChar,&hPrinter,NULL)==0)
            return false;
        
        DWORD bytesNeeded;
        ::GetPrinter(hPrinter,2,0,0,&bytesNeeded);
        PRINTER\_INFO\_2 \*pf=(PRINTER\_INFO\_2 \*)GlobalAlloc(GPTR,bytesNeeded);
        
        if(::GetPrinter(hPrinter,2,(LPBYTE)pf,bytesNeeded,&bytesNeeded)!=0)
            if(pf->cJobs==0 && pf->Status==0)
                bResult=true;
        
        GlobalFree(pf);
        
        ClosePrinter(hPrinter);
        
        return bResult;
        

        }

        What changes must be made in the code? Thanks.

        D Offline
        D Offline
        Dave Doknjas
        wrote on last edited by
        #3

        Are you sure you want 2002 Managed C++? The pre-CLI managed C++ syntax was a failed experiment - the syntax was available only for a short time and it was quickly superceded by C++/CLI (even C++/CLI is not commonly used).

        David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups