DRIVER_INFO_ structure

This is a discussion on DRIVER_INFO_ structure within the Windows Programming forums, part of the Platform Specific Boards category; I have been glancing at this link http://msdn.microsoft.com/en-us/libr...13(VS.85).aspx to learn more about how to use the function, but I'm confused ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    222

    DRIVER_INFO_ structure

    I have been glancing at this link http://msdn.microsoft.com/en-us/libr...13(VS.85).aspx to learn more about how to use the function, but I'm confused about the differences between each DRIVER_INFO structure beside which operating system each can be used under. It just lists its members under the description of each DRIVER_INFO structure. Any type of explanations would be much appreciated. Thanks.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,699
    Google'n found example usage here: http://www.google.com/codesearch?hl=.../ThirdPage.cpp

    Params:
    Level - which structure you want
    pcReturned - number of structures returned.

    So you call it the first time to see how much memory you need. Then call again to get an array of the requested structures. pcReturned tells you have many structures there are in the array.

    gg

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    222
    Thanks for your reply. I guess my initial confusion was which structure to pick in the first place. Do you have any recommendations besides picking the newest one possible?

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,699
    Depends on what information you're looking for, and what win-flavors you intend to run on. It's up to you.

    gg

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    222
    I have another question about the structure. Right now I have some code that looks like this, which uses a similar structure as the example that you've pulled up:

    Code:
    PDFPRNINSTAPI BOOL PDFPRNINSTCALL PdfPrnInstDriverExistsW(WCHAR* pServerName,
    														  WCHAR* pDriverName)
    {
    	// variable declarations
    	//PDRIVER_INFO_6W pinfo = NULL;
    	LPBYTE pinfo = NULL;
    	DWORD pcbNeeded;				// just to hold info on amount of bytes copied to
    											// driverInfo buffer
    	DWORD numDriversExist;			// Number of drivers exist
    
    	BOOL ok;
    
    	// enumerates installed drivers
    	EnumPrinterDriversW(NULL,
    					   NULL,
    					   6,			/* level uses the latest one */
    					   NULL,
    					   0,
    					   &pcbNeeded,
    					   &numDriversExist
    		);
    
    	if(pcbNeeded > 0)
    	{
    		try
    		{
    			pinfo = (LPBYTE) malloc(pcbNeeded);
    		}
    		catch (char* e)
    		{
    			pinfo = NULL;
    			printf("Exception raised: %s\n", e);
    		}
    
    		// now find the printer with the driver name
    		ok = EnumPrinterDriversW(NULL,
    								 NULL,
    								 6,
    								 pinfo,
    								 pcbNeeded,
    								 &pcbNeeded,
    								 &numDriversExist);
    		DRIVER_INFO_6W *foundInfo = (DRIVER_INFO_6W*) pinfo;
    
    		for (DWORD i=0; i < numDriversExist; i++)
    		{
    			// Print out information on the printers
    			cout << "Iteration " << i << endl;
    			cout << "pName = " << foundInfo[i].pName << endl;
    			cout << "pDriverPath = " << foundInfo[i].pDriverPath << endl;
    		}
    
    		// Print out numDriversExist references
    		printf("pcbNeeded = %d\n", pcbNeeded);
    		printf("numDriversExist = %d\n", numDriversExist);
    	}
    
    
    	// return true if the printer driver exists, else false
    	return true;
    }
    My question is that for my test cout statements, I'm always getting outputs that show a sequence of 8 hexadecimal numbers. Could that be b/c of the unicode business? Also, would there be any specific guidelines on finding a printer driver with a particular cell information?

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,699
    >> Could that be b/c of the unicode business?
    Yeah. You can use wcout for wide strings.
    Code:
                wcout << L"pName = " << foundInfo[i].pName << endl;
                wcout << L"pDriverPath = " << foundInfo[i].pDriverPath << endl;
    >> any specific guidelines on finding a printer driver with a particular cell information?
    Not sure what you mean by "cell information" - but these API's are all new to me anyways

    Other code improvements:
    - mixing C and C++ a bit - using malloc instead of new, printf(), etc..
    - error checking

    gg
    Last edited by Codeplug; 06-02-2008 at 01:40 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem referencing structure elements by pointer
    By trillianjedi in forum C Programming
    Replies: 19
    Last Post: 06-13-2008, 06:46 PM
  2. Replies: 5
    Last Post: 02-14-2006, 09:04 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM
  5. C structure within structure problem, need help
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 11-30-2001, 05:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21