示例#1
0
    static int
        max_filename()
    {
        DWORD maxflen;
        int status = 0;

        status = GetVolumeInformation((LPTSTR)0, (LPTSTR)0, 0
            , (LPDWORD)0, &maxflen, (LPDWORD)0, (LPTSTR)0, 0);
        if (status) return maxflen;
        else return 0;
    }
示例#2
0
String GetVolumeSn(const String &vol, int len) {
	dword sn;
	
	// Win API
	if(!GetVolumeInformation(vol, NULL, 0, &sn, NULL, NULL, NULL, 0)) sn = 71511731;
#ifdef _WITH_DEBUG
RLOG("GetVolumeSn():sn = " + AsString(sn));
#endif	
	
	return String(AsString(sn)).Right(len);
}
示例#3
0
/* Tony Hoyle's function for testing whether a given volume uses UTC or 
 * local time to record file modification times
 * 
 * Reproduced here with permission of Tony Hoyle.
 * 
 * This code is copyright by Tony Hoyle and is licensed under the Gnu 
 * Public License. (See above)
 *
 * NTFS, HPFS, and OWFS store file times as UTC times.
 * FAT stores file times as local time.
 *
 * INPUTS:
 *      LPCSTR name: fully qualified path
 *
 * OUTPUTS:
 *      Return true if the file system on the volume in question 
 *      stores file times as UTC
 */
BOOL IsUTCVolume ( LPCTSTR name )
{
    _TCHAR szDrive[_MAX_DRIVE + 1] = _T("");
    _TCHAR szFs[32]=_T("");
    _tsplitpath(name, szDrive, NULL, NULL, NULL);

    _tcscat(szDrive, _T("\\"));
    GetVolumeInformation( szDrive, NULL, 0, NULL, NULL, NULL, szFs, 32 );
    return ! ( _tcsicmp( szFs, _T("NTFS") ) 
               && _tcsicmp( szFs, _T("HPFS") ) 
               && _tcsicmp( szFs, _T("OWFS") ) );
}
示例#4
0
//===========================================================================
void __fastcall TfrmMain::FormCreate(TObject *Sender)
{
   // ---------------------------------------------------
    frmLogoDiALab = new TfrmLogoDiALab(NULL);
    //frmLogoDiALab->Show();
    Application->ProcessMessages();
    Sleep(2300);
   // ---------------------------------------------------
      WhoUseProgram = wupSensei;
      //WhoUseProgram = wupTsisarzh;
      //WhoUseProgram = wupTanjaKvant;

      if (WhoUseProgram == wupTsisarzh) { // ---- ѕровер¤ем винты ------// || WhoUseProgram == wupSensei
            unsigned long  aa = MAX_PATH;
            char           VolumeName[MAX_PATH], FileSystemName[MAX_PATH];
            unsigned long  VolumeSerialNo;
            unsigned long  MaxComponentLength, FileSystemFlags;

            GetVolumeInformation("C:\\", VolumeName, aa, &VolumeSerialNo,
                                 &MaxComponentLength,&FileSystemFlags,
                                 FileSystemName,aa);

            AnsiString  HexVolumeSerialNo = IntToHex((int)VolumeSerialNo,8);

            if ( HexVolumeSerialNo != "0D471DF1" && HexVolumeSerialNo != "104E16FB" && HexVolumeSerialNo != "256E13FC") {
                Error_None_LicenseProgram(Handle);
                ExitProcess(0);
            }
      }

   // ---------------------------------------------------
      Left   = 0;
      Top    = 0;
      Height = 730;
      EnabledTVModivication = true;

   // ---- –егистрирую в ¬индовсе расширение ------------
      RegisterFileType("dls", Application->ExeName, 1);
      AddNewFileToMainMenu(pmFile, "Load", LoadProjectFromMenu);

   // ------- «аполн¤ем “ри¬ью —писками элементов -----
      SetupTreeView();

   // -------
      aAllAction(aNewScheme);

   // ------- »нициализаци¤ пути ќпен и —айф ƒиалога --------
      OpenDialog1->InitialDir =  ExtractFilePath( Application->ExeName );
      SaveDialog1->InitialDir =  ExtractFilePath( Application->ExeName );

   // -----
      TimerLogo->Enabled = true;
}
	void Win32DiskInfoProvider::ConstructInfo()
	{
		TCHAR VolumeNameBuffer[MAX_PATH+1];
		DWORD VolumeSerialNumber=0;
		DWORD MaximumComponentLength=0;
		DWORD FileSystemFlags=0;
		TCHAR FileSystemNameBuffer[MAX_PATH+1];
		BOOL b = GetVolumeInformation(driveName.c_str(), VolumeNameBuffer, MAX_PATH+1,
			&VolumeSerialNumber, &MaximumComponentLength, &FileSystemFlags,
			FileSystemNameBuffer, MAX_PATH+1);

		if (!b)
		{
			valid = false;
			info = "error";
			return;
		}

		ULARGE_INTEGER totalNrBytes;
		totalNrBytes.QuadPart = 0;
		GetDiskFreeSpaceEx(driveName.c_str(), NULL, &totalNrBytes, NULL);

		std::string strType;
		switch (GetDriveType(driveName.c_str()))
		{
		case DRIVE_UNKNOWN:
			strType += "unknown volume type";
			break;
		case DRIVE_NO_ROOT_DIR:
			strType += "invalid root dir";
			break;
		case DRIVE_REMOVABLE:
			strType += "removable volume";
			break;
		case DRIVE_FIXED:
			strType += "fixed volume";
			break;
		case DRIVE_REMOTE:
			strType += "remote volume";
			break;
		case DRIVE_CDROM:
			strType += "CD-ROM";
			break;
		case DRIVE_RAMDISK:
			strType += "RAM disk";
			break;
		}
		info = driveName+
			" type:<"+strType+
			">, name:<"+VolumeNameBuffer+
			">, system name:<"+FileSystemNameBuffer+
			">, "+RichBool::ToString(totalNrBytes)+" bytes";
	}
示例#6
0
BOOL
IsVolumeNTFS(
    PWCHAR path
    )
{
    //
    //  Scan backwards through the path looking for \ and trying at each level until we
    //  get to the root. We'll terminate it there and pass it to GetVolumeInformation
    //

    PWCHAR LastBackSlash = path + wcslen( path );
    WCHAR c;
    BOOL b;
    ULONG i;
    WCHAR PhysicalName[MAX_PATH];

    
    while (TRUE) {
        while (TRUE) {
            if (LastBackSlash < path) {
                DisplayError();
                return FALSE;
            }

            if (*LastBackSlash == L'\\') {
                break;
            }

            LastBackSlash--;
        }

        c = LastBackSlash[1];
        LastBackSlash[1] = L'\0';

        b = GetVolumeInformation(
            path,
            NULL,
            0,
            NULL,
            &i,
            &i,
            PhysicalName,
            sizeof(PhysicalName)/sizeof(WCHAR)
            );

        LastBackSlash[1] = c;
        LastBackSlash--;

        if ( b ) {
            return _wcsicmp( PhysicalName, L"NTFS" ) == 0;
        }
    }
}
示例#7
0
// turn a file, relative path or other into an absolute path
BOOL AFXAPI AfxFullPath(LPTSTR lpszPathOut, LPCTSTR lpszFileIn)
	// lpszPathOut = buffer of _MAX_PATH
	// lpszFileIn = file, relative path or absolute path
	// (both in ANSI character set)
{
	ASSERT(AfxIsValidAddress(lpszPathOut, _MAX_PATH));

	// first, fully qualify the path name
	LPTSTR lpszFilePart;
	if (!GetFullPathName(lpszFileIn, _MAX_PATH, lpszPathOut, &lpszFilePart))
	{
#ifdef _DEBUG
		if (lpszFileIn[0] != '\0')
			TRACE1("Warning: could not parse the path '%s'.\n", lpszFileIn);
#endif
		lstrcpyn(lpszPathOut, lpszFileIn, _MAX_PATH); // take it literally
		return FALSE;
	}

#ifndef _MAC
	CString strRoot;
	// determine the root name of the volume
	AfxGetRoot(lpszPathOut, strRoot);

	// get file system information for the volume
	DWORD dwFlags, dwDummy;
	if (!GetVolumeInformation(strRoot, NULL, 0, NULL, &dwDummy, &dwFlags,
		NULL, 0))
	{
		TRACE1("Warning: could not get volume information '%s'.\n",
			(LPCTSTR)strRoot);
		return FALSE;   // preserving case may not be correct
	}

	// not all characters have complete uppercase/lowercase
	if (!(dwFlags & FS_CASE_IS_PRESERVED))
		CharUpper(lpszPathOut);

	// assume non-UNICODE file systems, use OEM character set
	if (!(dwFlags & FS_UNICODE_STORED_ON_DISK))
	{
		WIN32_FIND_DATA data;
		HANDLE h = FindFirstFile(lpszFileIn, &data);
		if (h != INVALID_HANDLE_VALUE)
		{
			FindClose(h);
			lstrcpy(lpszFilePart, data.cFileName);
		}
	}
#endif
	return TRUE;
}
bool GetHdiskID(TCHAR DiskID[10])
{
	DWORD Serial;
	DWORD Length;
	BOOL success = GetVolumeInformation(_T("C:\\"), NULL, MAX_PATH, &Serial, &Length, NULL, NULL, MAX_PATH);
	if (!success)
	{
		return false;
	}

	wsprintf(DiskID, _T("%x"), Serial);
	return true;
} 
void TautoPresetProps::getVolume(void)
{
    const char_t *flnm=deci->getSourceName();
    char_t dsk[MAX_PATH];
    _splitpath_s(flnm,dsk,MAX_PATH,NULL,0,NULL,0,NULL,0);
    DWORD serial,maximumComponentLength,volumeFlags;
    ffstring disk(dsk);
    disk += _l("\\");
    wasVolume=GetVolumeInformation(disk.c_str(),volumeName,256,&serial,&maximumComponentLength,&volumeFlags,NULL,0);
    if (wasVolume) {
        tsnprintf_s(volumeSerial, countof(volumeSerial), _TRUNCATE, _l("%X-%X"),(int)HIWORD(serial),(int)LOWORD(serial));
    }
}
示例#10
0
bool IdentClient::SendParaSysStorage()
{
	bool bRet = false;
	if (m_IsSvrConnected)
	{
		memset(&m_cmdTransfer,0x00,sizeof(m_cmdTransfer));
		size_t szAllDriveStrings = GetLogicalDriveStrings(0,NULL);
		char *pDriveStrings = new char[szAllDriveStrings + sizeof((""))];
		GetLogicalDriveStrings(szAllDriveStrings,pDriveStrings);
		size_t szDriveString = strlen(pDriveStrings);
		int iMaxnumDrive = sizeof(g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc)/sizeof(g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[0]);
		int DriveIndex = 0;
		for(DriveIndex = 0; DriveIndex < iMaxnumDrive && szDriveString > 0; DriveIndex++)
		{
			strcpy((char *)g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].disk_name,pDriveStrings);
			unsigned long long FreeAv,TotalBytes,FreeBytes;
			if (GetDiskFreeSpaceEx(pDriveStrings,&FreeAv,&TotalBytes,&FreeBytes))
			{
				g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].realsize = TotalBytes.QuadPart/(unsigned long long)(1024*1024);
				g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].emptysize = FreeAv.QuadPart/(unsigned long long)(1024*1024);
			}
			g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_type = (DRIVE_TYPE)GetDriveType(pDriveStrings);
			char drive_fs_type[128];
			if(!GetVolumeInformation(pDriveStrings,NULL,0,NULL,NULL,NULL,drive_fs_type,128))
			{
				g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_fstype = DRIVE_FS_TYPE_UNKNOWN;
			}
			else
			{
				if(!strcmp(drive_fs_type,"NTFS"))
				{
					g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_fstype = DRIVE_FS_TYPE_NTFS;
				}
				else if(!strcmp(drive_fs_type,"FAT32"))
				{
					g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_fstype = DRIVE_FS_TYPE_FAT32;
				}
				else
				{
					g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_fstype = DRIVE_FS_TYPE_UNKNOWN;
				}
			}
			pDriveStrings += szDriveString + 1;
			szDriveString = strlen(pDriveStrings);
		}
		g_stGlobal_Flash.sysstoragepara.storageconfig.diskcount = DriveIndex;
		bRet = CONSTRUCT_CMD(CMD_NUM_SYS_STORAGE_RESPONSE,(char *)&g_stGlobal_Variable.globalflash.sysstoragepara,sizeof(SYS_STORAGE_PARA),&m_cmdTransfer);
		bRet &= SendParaMsg();
	}
	return bRet;
}
示例#11
0
文件: platform.cpp 项目: Bobakka/uhd
    boost::uint32_t get_host_id() {
#ifdef UHD_PLATFORM_WIN32
        //extract volume serial number
        char szVolName[MAX_PATH+1], szFileSysName[MAX_PATH+1];
        DWORD dwSerialNumber, dwMaxComponentLen, dwFileSysFlags;
        GetVolumeInformation("C:\\", szVolName, MAX_PATH,
            &dwSerialNumber, &dwMaxComponentLen,
            &dwFileSysFlags, szFileSysName, sizeof(szFileSysName));

        return boost::uint32_t(dwSerialNumber);
#else
        return boost::uint32_t(gethostid());
#endif
    }
示例#12
0
bool CVolumeDescriptionEnumeratorThread::GetDrive(const wxChar* pDrive, const int len)
{
	wxChar* pVolume = new wxChar[len + 1];
	wxStrcpy(pVolume, pDrive);
	if (pVolume[len - 1] == '\\')
		pVolume[len - 1] = 0;
	if (!*pVolume)
	{
		delete [] pVolume;
		return false;
	}

	// Check if it is a network share
	wxChar *share_name = new wxChar[512];
	DWORD dwSize = 511;
	if (!WNetGetConnection(pVolume, share_name, &dwSize))
	{
		m_crit_section.Enter();
		t_VolumeInfoInternal volumeInfo;
		volumeInfo.pVolume = pVolume;
		volumeInfo.pVolumeName = share_name;
		m_volumeInfo.push_back(volumeInfo);
		m_crit_section.Leave();
		pDrive += len + 1;
		return true;
	}
	else
		delete [] share_name;

	// Get the label of the drive
	wxChar* pVolumeName = new wxChar[501];
	int oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
	BOOL res = GetVolumeInformation(pDrive, pVolumeName, 500, 0, 0, 0, 0, 0);
	SetErrorMode(oldErrorMode);
	if (res && pVolumeName[0])
	{
		m_crit_section.Enter();
		t_VolumeInfoInternal volumeInfo;
		volumeInfo.pVolume = pVolume;
		volumeInfo.pVolumeName = pVolumeName;
		m_volumeInfo.push_back(volumeInfo);
		m_crit_section.Leave();
		return true;
	}

	delete [] pVolumeName;
	delete [] pVolume;

	return false;
}
示例#13
0
std::string volume_name(const std::string &path)
{
    wchar_t volume_name[MAX_PATH + 1];
    if (GetVolumeInformation(
                to_windows_path(path).c_str(),
                volume_name,
                sizeof(volume_name) / sizeof(*volume_name),
                NULL, NULL, NULL, NULL, 0))
    {
        return from_utf16(volume_name);
    }

    return std::string();
}
示例#14
0
/*
 * Class:     sage_Sage
 * Method:    getFileSystemType
 * Signature: (Ljava/lang/String;)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_sage_Sage_getFileSystemType(JNIEnv *env, jclass jc, jstring volRoot)
{
	const char* rootStr = env->GetStringUTFChars(volRoot, 0);
	DWORD maxNameLen;
	DWORD fsFlags;
	TCHAR daBuf[64];
	jstring rv;
	if (GetVolumeInformation(rootStr, NULL, 0, NULL, &maxNameLen, &fsFlags, daBuf, 64))
		rv = env->NewStringUTF(daBuf);
	else
		rv = NULL;
	env->ReleaseStringUTFChars(volRoot, rootStr);
	return rv;
}
示例#15
0
文件: fsaccess.c 项目: ryo/netbsd-src
BOOL
is_ntfs(const char * file) {

    char drive[255];
    char FSType[20];
    char tmpbuf[256];
    char *machinename;
    char *sharename;
    char filename[1024];

    REQUIRE(filename != NULL);

    if (isc_file_absolutepath(file, filename,
                              sizeof(filename)) != ISC_R_SUCCESS) {
        return (FALSE);
    }

    /*
     * Look for c:\path\... style, c:/path/... or \\computer\shar\path...
     * the UNC style file specs
     */
    if (isalpha(filename[0]) && filename[1] == ':' &&
            (filename[2] == '\\' || filename[2] == '/')) {
        strncpy(drive, filename, 3);
        drive[3] = '\0';
    }

    else if ((filename[0] == '\\') && (filename[1] == '\\')) {
        /* Find the machine and share name and rebuild the UNC */
        strcpy(tmpbuf, filename);
        machinename = strtok(tmpbuf, "\\");
        sharename = strtok(NULL, "\\");
        strcpy(drive, "\\\\");
        strcat(drive, machinename);
        strcat(drive, "\\");
        strcat(drive, sharename);
        strcat(drive, "\\");

    }
    else /* Not determinable */
        return (FALSE);

    GetVolumeInformation(drive, NULL, 0, NULL, 0, NULL, FSType,
                         sizeof(FSType));
    if(strcmp(FSType,"NTFS") == 0)
        return (TRUE);
    else
        return (FALSE);
}
示例#16
0
文件: porting.c 项目: dong1/testsize
/*
 * pathconf -
 *   return:
 *   path(in):
 *   name(in):
 *
 * Note:
 */
long
pathconf (char *path, int name)
{

  long namelen;
  long filesysflags;

  switch (name)
    {
    case _PC_PATH_MAX:
      /*
       * NT and OS/2 file systems claim to be able to handle 255 char
       * file names.  But none of the system calls seem to be able to
       * handle a path of more than 255 chars + 1 NULL.  Nor does there
       * appear to be a system function to return the real max length.
       * MAX_PATH is defined in stdlib.h on the NT system.
       */
      return ((MAX_PATH - 1));

    case _PC_NAME_MAX:
      if (GetVolumeInformation
	  (NULL, NULL, 0, NULL, (LPDWORD) & namelen, (LPDWORD) & filesysflags,
	   NULL, 0))
	{
	  /* WARNING!, for "old" DOS style file systems, namelen will be 12
	   * right now, totaling the 8 bytes for name with the 3 bytes for
	   * for extension plus a dot.  This ISN'T what the caller wants,
	   * It really wants the maximum size of an unqualified pathname.
	   * I'm not sure what this works out to be under the new file system.
	   * We probably need to make a similar adjustment but hopefully
	   * we'll have more breathing room.
	   */
	  if (namelen == 12)
	    namelen = 8;

	  return (namelen);
	}
      else
	{
	  return (8);		/* Length of MSDOS file name */
	}

    case _PC_NO_TRUNC:
      return (TRUE);

    default:
      return (-1);
    }
}
示例#17
0
MonoBoolean
ves_icall_Mono_Security_Cryptography_KeyPairPersistence_CanSecure (MonoString *root)
{
#if HOST_WIN32
	gint32 flags;

	/* ACL are nice... unless you have FAT or other uncivilized filesystem */
	if (!GetVolumeInformation (mono_string_chars (root), NULL, 0, NULL, NULL, (LPDWORD)&flags, NULL, 0))
		return FALSE;
	return ((flags & FS_PERSISTENT_ACLS) == FS_PERSISTENT_ACLS);
#else
	/* we assume some kind of security is applicable outside Windows */
	return TRUE;
#endif
}
示例#18
0
APIRET os2APIENTRY DosQueryFSAttach(PCSZ   pszDeviceName,
                                    ULONG  /*ulOrdinal*/,
                                    ULONG  ulFSAInfoLevel,
                                    PFSQBUFFER2 pfsqb,
                                    PULONG /*pcbBuffLength*/)
{
        //FixMe: handle devices too
        if(ulFSAInfoLevel!=FSAIL_QUERYNAME)
                return 124; //invalid level
        UINT dt = GetDriveType(pszDeviceName);
        switch(dt) {
                case DRIVE_REMOVABLE:
                        pfsqb->iType = FSAT_LOCALDRV; break;
                case DRIVE_FIXED:
                        pfsqb->iType = FSAT_LOCALDRV; break;
                case DRIVE_REMOTE:
                        pfsqb->iType = FSAT_REMOTEDRV; break;
                case DRIVE_CDROM:
                        pfsqb->iType = FSAT_LOCALDRV; break;
                case DRIVE_RAMDISK:
                        pfsqb->iType = FSAT_LOCALDRV; break;
                default:
                        return 15; //invalid drive
        }

        char volumeNameBuffer[256];
        DWORD mcl;
        DWORD fsf;
        char fsNameBuffer[256];
        if(!GetVolumeInformation(pszDeviceName,
                                 volumeNameBuffer,
                                 256,
                                 0,
                                 &mcl,
                                 &fsf,
                                 fsNameBuffer,
                                 256
                                ))
                return (APIRET)GetLastError();

        pfsqb->cbName = (USHORT)strlen(fsNameBuffer);
        strcpy((char*)pfsqb->szName,fsNameBuffer);
        pfsqb->cbFSDName = (USHORT)strlen(fsNameBuffer);
        strcpy((char*)pfsqb->szName+pfsqb->cbName+1,fsNameBuffer);
        pfsqb->cbFSAData = 0;

        return 0;
}
示例#19
0
文件: dir.c 项目: RareHare/reactos
/*
 * PrintDirectoryHeader
 *
 * print the header for the dir command
 */
static BOOL
PrintDirectoryHeader(LPTSTR szPath, LPDIRSWITCHFLAGS lpFlags)
{
  TCHAR szMsg[RC_STRING_MAX_SIZE];
  TCHAR szFullDir[MAX_PATH];
  TCHAR szRootName[MAX_PATH];
  TCHAR szVolName[80];
  LPTSTR pszFilePart;
  DWORD dwSerialNr;

  if (lpFlags->bBareFormat)
    return TRUE;

  if (GetFullPathName(szPath, sizeof(szFullDir) / sizeof(TCHAR), szFullDir, &pszFilePart) == 0)
    {
      ErrorMessage(GetLastError(), _T("Failed to build full directory path"));
      return FALSE;
    }

  if (pszFilePart != NULL)
      *pszFilePart = _T('\0');

  /* get the media ID of the drive */
  if (!GetVolumePathName(szFullDir, szRootName, sizeof(szRootName) / sizeof(TCHAR)) ||
      !GetVolumeInformation(szRootName, szVolName, 80, &dwSerialNr,
			    NULL, NULL, NULL, 0))
    {
      return(TRUE);
    }

  /* print drive info */
  if (szVolName[0] != _T('\0'))
    {
      LoadString(CMD_ModuleHandle, STRING_DIR_HELP2, szMsg, RC_STRING_MAX_SIZE);
      DirPrintf(lpFlags, szMsg, szRootName[0], szVolName);
    }
  else
    {
      LoadString(CMD_ModuleHandle, STRING_DIR_HELP3, szMsg, RC_STRING_MAX_SIZE);
      DirPrintf(lpFlags, szMsg, szRootName[0]);
    }

  /* print the volume serial number if the return was successful */
  LoadString(CMD_ModuleHandle, STRING_DIR_HELP4, (LPTSTR) szMsg, RC_STRING_MAX_SIZE);
  DirPrintf(lpFlags, szMsg, HIWORD(dwSerialNr), LOWORD(dwSerialNr));

  return TRUE;
}
示例#20
0
DWORD GetSystemVolumeSerial(char *szSystemVolume)
{
	char *lpszVolumeName, *lpszFileSystemName;
	DWORD dwVolumeSerialNumber = 0xFFFFFFFF, dwMaximumComponentLength, dwFileSystemFlags;

	lpszVolumeName = (char *)malloc(MAX_PATH + 1);
	if(lpszVolumeName != NULL){
		lpszFileSystemName = (char *)malloc(MAX_PATH * 1);
		if(lpszFileSystemName != NULL){
			GetVolumeInformation(szSystemVolume, lpszVolumeName, MAX_PATH + 1, &dwVolumeSerialNumber, &dwMaximumComponentLength, &dwFileSystemFlags, lpszFileSystemName, MAX_PATH + 1);
			free(lpszFileSystemName);
		}
		free(lpszVolumeName);
	}
	return dwVolumeSerialNumber;
}
示例#21
0
bool FileSystemManager::resolveVolumeName( QString volume, QString& volumeNameOut )
{
	if (!exists(volume))
		return false;

	// derive the drive name from the drive letter
	TCHAR volumeName[MAX_PATH];
	volumeNameOut = QString("Removable Disk (%1)").arg(volume);
	if (GetVolumeInformation((LPCTSTR) volume.utf16(), volumeName, MAX_PATH, NULL, NULL, NULL, NULL, 0))
	{
		QString tmp = QString::fromUtf16((const ushort *) volumeName);
		if (!tmp.isEmpty())
			volumeNameOut = tmp;
	}	
	return true;
}
示例#22
0
/*------------------------------------------------------------------------------------

FUNCTION NAME: GetSerialNumber

DESCRIPTION:   Get serial number from BIOS.


PARAMETERS:
  - INPUT:
  - OUTPUT:

RETURN:
  - TRUE  : Get information correctly.
  - FALSE : Not get information correctly.

NOTES:

------------------------------------------------------------------------------------*/
BOOL   GetSerialNumber (DWORD  * pSerialNumber, char * RootDirectory)
{
  char        _volume_name [MAX_MGL_STRINGS];
  char        _file_system_name [MAX_MGL_STRINGS];
  DWORD       _size;
  DWORD       _serial_number, _max_component_length, _file_system_flags;
  BOOL        _rc;

  _size = MAX_MGL_STRINGS;

  _rc = GetVolumeInformation (RootDirectory, _volume_name, _size, &_serial_number, &_max_component_length, &_file_system_flags, _file_system_name, _size);

  *pSerialNumber = _serial_number;

  return _rc;

} /* GetSerialNumber */
示例#23
0
bool IsFilenameOnFATVolume(const char *pszFilename) {
	char szFileRoot[MAX_PATH];
	DWORD dwMaxComponentLength;
	DWORD dwFSFlags;
	char szFilesystem[MAX_PATH];

	if (!GetVolumeInformation(SplitPathRoot(szFileRoot, pszFilename),
			NULL, 0,		// Volume name buffer
			NULL,			// Serial number buffer
			&dwMaxComponentLength,
			&dwFSFlags,
			szFilesystem,
			sizeof szFilesystem))
		return false;

	return !strnicmp(szFilesystem, "FAT", 3);
}
//---------------------------------------------------------------------------
// Returns the type of filesystem that a file resides on.
//
AnsiString GetFileSystemType(AnsiString FileName)
{
  AnsiString retval;
  char *VolumeName, *FileSystemName;
  DWORD VolumeSerialNumber, MaxComponentLength, FileSystemFlags;
  bool success;

  VolumeName = new char[MAX_PATH];
  FileSystemName = new char[MAX_PATH];
  success = GetVolumeInformation((ExtractFileDrive(FileName) + "\\").c_str(), VolumeName, MAX_PATH, &VolumeSerialNumber, &MaxComponentLength, &FileSystemFlags, FileSystemName, 64);
  if (success)
    retval = String(FileSystemName);
  delete VolumeName;
  delete FileSystemName;

  return String(FileSystemName);
}  // AnsiString GetFileSystemType(AnsiString FileName)
示例#25
0
static BOOL mediaInDrive(const char *drive)
{
    UINT oldErrorMode;
    DWORD tmp;
    BOOL retval;

    /* Prevent windows warning message appearing when checking media size */
    oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);

    /* If this function succeeds, there's media in the drive */
    retval = GetVolumeInformation(drive, NULL, 0, NULL, NULL, &tmp, NULL, 0);

    /* Revert back to old windows error handler */
    SetErrorMode(oldErrorMode);

    return(retval);
} /* mediaInDrive */
示例#26
0
void InitDrive(int i){
	WCHAR name[4];
	g_bVols[i]=1;
	swprintf(name,4,L"%c:\\",i+'A');
	g_VolsInfo[i].type = GetDriveType(name);
	if(g_VolsInfo[i].type==DRIVE_FIXED){
		if(IsUsbDriver(i)) g_VolsInfo[i].type=DRIVE_REMOVABLE;
	}
	{
		WCHAR volumeName[32];
		WCHAR fsName[8];
		GetVolumeInformation(name,volumeName,32,&g_VolsInfo[i].serialNumber,NULL,NULL,fsName,8);
		wchar_to_utf8_nocheck(volumeName, 32, g_VolsInfo[i].volumeName, 56);
		wchar_to_utf8_nocheck(fsName, 8, g_VolsInfo[i].fsName, 8);
	}
	get_drive_space(i);
}
示例#27
0
/**
 * \class MediaMonitorWindows
 *
 * I am assuming, for now, that everything on Windows uses drive letters
 * (e.g. C:, D:). That is probably wrong, though. (other APIs?)
 */
MediaMonitorWindows::MediaMonitorWindows(QObject* par,
                                         unsigned long interval,
                                         bool allowEject)
                   : MediaMonitor(par, interval, allowEject)
{
    char strDrives[128];
    if (!::GetLogicalDriveStrings(sizeof(strDrives), strDrives))
        return;

    for (char *driveName = strDrives; *driveName;
         driveName += strlen(driveName) + 1)
    {
        uint type = ::GetDriveType(driveName);
        if (type != DRIVE_REMOVABLE && type != DRIVE_CDROM)
            continue;

        MythMediaDevice *media = NULL;

        if (type == DRIVE_CDROM)
            media = MythCDROM::get(this, driveName, false, allowEject);
        else
            media = MythHDD::Get(this, driveName, false, allowEject);

        if (!media)
        {
            VERBOSE(VB_IMPORTANT,
                    "Error. Couldn't create MythMediaDevice.");
            return;
        }

        // We store the volume name to improve
        // user activities like ChooseAndEjectMedia().
        char volumeName[MAX_PATH];
        if (GetVolumeInformation(driveName, volumeName, MAX_PATH,
                                 NULL, NULL, NULL, NULL, NULL))
        {
            media->setVolumeID(volumeName);
        }

        AddDevice(media);
    }

    VERBOSE(VB_MEDIA, "Initial device list: " + listDevices());
}
示例#28
0
    bool GetMachineID(std::string &info)
    {
        const int CBuffSize = 256;

        // get windows path
        std::wstring dir;
        {
            wchar_t buff[CBuffSize];
            int len = GetWindowsDirectory(buff, CBuffSize);
            if (len > CBuffSize) return false;
            dir += buff;
        }



        // get volume info
        DWORD volumeID;
        {
            wchar_t volume[CBuffSize];
            wchar_t fsName[CBuffSize];
            DWORD componentLength, systemFlags;

			
            bool ok = GetVolumeInformation(
                dir.substr(0, 3).c_str(),
                volume,
                CBuffSize,
                &volumeID,
                &componentLength,
                &systemFlags,
                fsName,
                CBuffSize
                );

            if (!ok) return false;
        }

        // volume id -> md5 -> base64
        std::string volumeIdHash;
        Utils::MD5::Digest(&volumeID, sizeof(volumeID), volumeIdHash);
        Utils::Base64::Encode(volumeIdHash, info);

        return true;
    }
示例#29
0
bool MyGetVolumeInformation(
    LPCTSTR rootPathName,
    CSysString &volumeName,
    LPDWORD volumeSerialNumber,
    LPDWORD maximumComponentLength,
    LPDWORD fileSystemFlags,
    CSysString &fileSystemName)
{
  bool result = BOOLToBool(GetVolumeInformation(
      rootPathName,
      volumeName.GetBuffer(MAX_PATH), MAX_PATH,
      volumeSerialNumber,
      maximumComponentLength,
      fileSystemFlags,
      fileSystemName.GetBuffer(MAX_PATH), MAX_PATH));
  volumeName.ReleaseBuffer();
  fileSystemName.ReleaseBuffer();
  return result;
}
示例#30
0
BOOL
IsVolumeLocalNTFS(
    WCHAR DriveLetter
    )
{
    BOOL b;
    ULONG i;
    WCHAR DosName[16];
    WCHAR PhysicalName[MAX_PATH];


    DosName[0] = DriveLetter;
    DosName[1] = L':';
    DosName[2] = L'\\';
    DosName[3] = L'\0';

    switch (GetDriveType( DosName )) {
    case DRIVE_UNKNOWN:
    case DRIVE_REMOTE:
        return FALSE;
    }
    
    b = GetVolumeInformation(
        DosName,
        NULL,
        0,
        NULL,
        &i,
        &i,
        PhysicalName,
        sizeof(PhysicalName)/sizeof(WCHAR)
        );
    if (!b ) {
        DisplayError();
        return FALSE;
    }

    if (_wcsicmp( PhysicalName, L"NTFS" ) != 0) {
        return FALSE;
    }

    return TRUE;
}