none
Error C2440: '=' : cannot convert from 'HLOCAL' to 'DRIVERSHELL_CONTEXT *' RRS feed

  • Question

  • Hello Friends,

    I am trying to read registry values with basic stream driver. In my TST_Init I am trying to allocate certain number of bytes using LocalAlloc but it displaying typecasting error. My code is as

    Test1.h

                    
    typedef struct _DRIVERSHELL_CONTEXT
    {
                    DWORD Instance;
    
    } DRIVERSHELL_CONTEXT;
    



    Test1.cpp

    DWORD TST_Init(
      LPCTSTR regPath,
      DWORD dwBusContext
    )
    {
    	HKEY	hKey;
    	DWORD	result;
    	DWORD Type	=	REG_DWORD;
    	DWORD Data;
    	DWORD DataSize	=	sizeof(DWORD);
    	DRIVERSHELL_CONTEXT *pDriverContext;
    
    
    	RETAILMSG(TRUE,(TEXT("TST_Init(): START\r\n")));
    
    		////pDriverContext = LocalAlloc(LMEM_FIXED, sizeof(DRIVERSHELL_CONTEXT));
    		pDriverContext = (pDriverContext)LocalAlloc(LMEM_FIXED, sizeof(DRIVERSHELL_CONTEXT));
    	
    		hKey = OpenDeviceKey((LPCTSTR)regPath);// This fxn opens the device registery key,


    The error is as - 

    Error 2 error C2440: 'type cast' : cannot convert from 'HLOCAL' to 'DRIVERSHELL_CONTEXT' {log="C:\WINCE700\platform\AM335xPhytec\SRC\DRIVERS\Test1\bldsys.log(30)"} c:\wince700\platform\am335xphytec\src\drivers\test1\test1.cpp 40

    I am following the Bruce Eitman link as -

    http://geekswithblogs.net/BruceEitman/archive/2010/08/01/windows-ce-using-a-driver-to-readwrite-hardware-registers.aspx

    If I remove the pDriverContext before LocalAlloc, still it display the same error.......

    Monday, March 24, 2014 5:24 AM

Answers

  • Have you tried

    pDriverContext = (DRIVERSHELL_CONTEXT *)LocalAlloc(LMEM_FIXED, sizeof(DRIVERSHELL_CONTEXT));

    ?


    Keshava G N Member - Technical (Software), iWave Systems, Bangalore <http://iwavesystems.com> mailto: keshavagn AT iwavesystems DOT com

    Monday, March 24, 2014 5:40 AM

All replies

  • Have you tried

    pDriverContext = (DRIVERSHELL_CONTEXT *)LocalAlloc(LMEM_FIXED, sizeof(DRIVERSHELL_CONTEXT));

    ?


    Keshava G N Member - Technical (Software), iWave Systems, Bangalore <http://iwavesystems.com> mailto: keshavagn AT iwavesystems DOT com

    Monday, March 24, 2014 5:40 AM
  • Thanks Keshava GN for answer.....
    Monday, March 24, 2014 6:26 AM