All pastes #970737 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-04-04 07:37 UTC
rendered paste body
#define WINVER       0x0500    // Enable W2K/98 features
#define _WIN32_WINNT 0x0500    // Enable W2K  features
#define _WIN32_IE    0x0500    // Enable IE 5+ features

#include <stdio.h>
#include <comdef.h>
#include <shlobj.h>
#include <shlguid.h>

// Prototypes

HRESULT IColumnProvider::Initialize ( LPCSHCOLUMNINIT psci );
HRESULT IColumnProvider::GetColumnInfo ( DWORD dwIndex, SHCOLUMNINFO* psci );
HRESULT IColumnProvider::GetItemData (
  LPCSHCOLUMNID   pscid,
  LPCSHCOLUMNDATA pscd,
  VARIANT*        pvarData );


class CMDLColExt :
  public CComObjectRootEx<CComSingleThreadModel>,
  public CComCoClass<CMDLColExt, &CLSID_MDLColExt>,
  public IColumnProvider
{
  BEGIN_COM_MAP(CMDLColExt)
    COM_INTERFACE_ENTRY_IID(IID_IColumnProvider, IColumnProvider)
  END_COM_MAP()
 
public:
  // IColumnProvider 

  STDMETHODIMP Initialize(LPCSHCOLUMNINIT psci) { return S_OK; }
  STDMETHODIMP GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO* psci);
  STDMETHODIMP GetItemData(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd,
                           VARIANT* pvarData);
};

STDMETHODIMP CMDLColExt::GetColumnInfo (
  DWORD dwIndex, SHCOLUMNINFO* psci )
{

  switch ( dwIndex )
    {
    case 0: 

      psci->scid.fmtid = CLSID_MDLColExt;     // Use our CLSID as the format ID

      psci->scid.pid   = 0;                   // Use the column # as the ID

      psci->vt         = VT_LPSTR;            // We'll return the data as a string

      psci->fmt        = LVCFMT_LEFT;         // Text will be left-aligned

      psci->csFlags    = SHCOLSTATE_TYPE_STR; // Data should be sorted as strings

      psci->cChars     = 4;                  // Default col width in chars

 
      wcsncpy ( psci->wszTitle, L"Model Version", MAX_COLUMN_NAME_LEN );
      wcsncpy ( psci->wszDescription, L"Version Of HL2 Models", MAX_COLUMN_DESC_LEN );
    break;
    }
}


// Start Krunchys MDL Version Stuff
struct basehdr_t
{
	int id;
	int version;
};

int main( int argc, char **argv )
{
	FILE *fp = fopen( argv[1], "rb" );
	basehdr_t *phdr = new basehdr_t;
	fread( phdr, 1, 8, fp ); //only bother reading 8 bytes, it's all we need to get the version.
	fclose( fp );
	
	printf( "Version: %i\n", phdr->version );
	
	delete phdr;
	return S_FALSE;
}