VIZ++ Class: CharModuleFileName

 VIZ++ Class Library  VIZ++ Samples  VIZ++ ClassTree 

Source code

/*
 * CharModuleFileName.h 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */



#pragma once

#include <viz++/Object.h>
#include <viz++/Exception.h>

namespace VIZ {

class CharModuleFileName :public Object {

private:
  char path[_MAX_PATH];
  char drive[_MAX_DRIVE];
  char dir[_MAX_DIR];
  char fileName[_MAX_FNAME];
  char ext[_MAX_EXT];

public:
  CharModuleFileName(HMODULE hModule = NULL)
  {
    memset(path,   0, CountOf(path)); 
    memset(drive,  0, CountOf(drive));
    memset(dir,    0, CountOf(dir));
    memset(ext,    0, CountOf(ext));
    
    DWORD rc = GetModuleFileNameA(hModule, path, CountOf(path));
    if(rc == 0) {
      throw IException("Failed to GetModuleFileName");
    }
    errno_t err = _splitpath_s(path,
                 drive, CountOf(drive),
                 dir,   CountOf(dir),
                 fileName,CountOf(fileName),
                  ext, CountOf(ext)); 
    if (err != NO_ERROR) {
      throw IException("Failed to _tsplitpath_s"); 
    }
  }
  
public:
  const char* getDrive() const
  {
    return drive;
  }
  
  const char* getDir() const
  {
    return dir;
  }
  
  const char* getFileName() const
  {
    return fileName;
  }

  const char* getExt() const 
  {
    return ext;
  }
};

}


Last modified: 10 Feb 2017

Copyright (c) 2009-2017 Antillia.com ALL RIGHTS RESERVED.