学习文章:

http://blog.sina.com.cn/s/blog_5f0215c70100d3j7.html  

WINCE与WM的差异(1)-查询文件系统目录结构

 

MSDN :http://msdn.microsoft.com/zh-cn/office/ee490204  Storage Manager Functions (Windows Embedded Compact 7)

(msdn,我用的太悲剧了,每次都不能快速的在目录索引下找到WinCE的目录,但偶尔翻的翻的就不知道怎么翻到WinCE的目录了,7也是。。。)

	HANDLE h_store;
	STOREINFO StoreInfo;
	StoreInfo.cbSize = sizeof(STOREINFO);
	h_store = FindFirstStore(&StoreInfo);
	if (h_store !=INVALID_HANDLE_VALUE)
	{
		printf("查找Store成功 \n");
		printf("szDeviceName =%ls\n", StoreInfo.szDeviceName);
		printf("szStoreName =%ls\n", StoreInfo.szStoreName);
		printf("dwDeviceClass =%d\n", StoreInfo.dwDeviceClass);
		printf("dwDeviceType =%d\n", StoreInfo.dwDeviceType);
		printf("dwDeviceFlags =%d\n", StoreInfo.dwDeviceFlags);
		printf("dwPartitionCount =%d\n", StoreInfo.dwPartitionCount);
		printf("dwMountCount =%d\n", StoreInfo.dwMountCount);
		/*	szDeviceName =DSK1:
			szStoreName =EMULATOR SHARED FOLDER FS
			dwDeviceClass =2
			dwDeviceType =536870912
			dwDeviceFlags =1
			dwPartitionCount =1
			dwMountCount =1*/
		HANDLE h_openStore;
		h_openStore = OpenStore(L"DSK1:");
		HANDLE h_part;
		PARTINFO PartInfo;
		PartInfo.cbSize = sizeof(PARTINFO);
		h_part = FindFirstPartition(h_openStore,&PartInfo);
		//FindFirstPartition第一个参数是OpenStore的返回值,不能用FindFirstStore的返回值
		if (h_part !=INVALID_HANDLE_VALUE)
		{
			printf("查找第一个Store分区成功\n");
			do 
			{
				
				printf("szPartitionName =%ls\n", PartInfo.szPartitionName);
				printf("szFileSys =%ls\n", PartInfo.szFileSys);
				printf("szVolumeName =%d\n", PartInfo.szVolumeName);
			} while (FindNextPartition(h_part,&PartInfo));

			/*szPartitionName =PART00
			szFileSys =VCEFSD.dll
			szVolumeName =324996*/
		}
		else
		{
			printf("查找第一个Store分区失败\n");
		}

		FindClosePartition(h_part);

	}

	if(FindNextStore(h_store,&StoreInfo))
	{
		printf("不止唯一Store\n");
	}
	else
	{
		printf("只有一个Store\n");
	}
	FindCloseStore(h_store);

  

输出的是模拟器的信息

还没结束,今天没时间测试了,也没机器,

工作的机器放资源的分区是隐藏的,每次放资源或程序的时候感觉忒麻烦。。尤其是心情烦躁的时候。

目标:做一个程序,一点击就修改注册表键值 ,将对应分区注册表隐藏设置为显示,然后卸载分区,再加载分区,应该会方便。

明天继续

---------------------------------------------------------------------------------------------------------------------------------

//将要显示的分区的注册表隐藏设置为假。

void CPartitionControlDlg::ChangeRegKeyValue()
{
	HKEY	hOpenKey;
	DWORD   dwKeyValueType = 0;
	DWORD	dwKeyValue;
	DWORD   dwKeyValueLength = sizeof(DWORD);
	if(ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, L"System\\StorageManager\\Profiles\\Nand\\NANDFATFS",0, 0, &hOpenKey ))
	{
		long lResult = 0;
		lResult = RegQueryValueExW( hOpenKey, L"MountHidden", 0, &dwKeyValueType,(BYTE*)&dwKeyValue, &dwKeyValueLength);
		if(lResult ==ERROR_SUCCESS)
		{
			printf("读取注册表成功,achKey = %d\n",dwKeyValue);
			dwKeyValue = 0;
			RegSetValueExW(hOpenKey,L"MountHidden",0,dwKeyValueType,(BYTE*)&dwKeyValue,dwKeyValueLength);
			
		}
		else
		{
			printf("读取失败 :lResult = %d\n",lResult);
		}
		
			//RegSetValueEx(hKey, TEXT("Screen"), 0, dwType, (LPBYTE)&dwData, dwDataLen);
		RegCloseKey( hOpenKey );
	}

}

  

//卸载、加载指定分区

void CPartitionControlDlg::OnBnClickedButton2()
{
	// TODO: Add your control notification handler code here

	ChangeRegKeyValue();

	HANDLE h_openStore;
	h_openStore = OpenStore(L"DSK1:");
	HANDLE h_NandPart;
	PARTINFO PartInfo;
	PartInfo.cbSize = sizeof(PARTINFO);
	h_NandPart = OpenPartition(h_openStore,L"Part01");

	if (DismountPartition(h_NandPart))
	{
		printf("NAND分区卸载成功\n");
	}
	else
	{
		printf("NAND分区卸载失败\n");
		MessageBox(L"显示NAND失败");
		CloseHandle(h_NandPart);
		CloseHandle(h_openStore);
		return;
	}
	if (MountPartition(h_NandPart))
	{
		printf("NAND分区加载成功\n");
	}
	else
	{
		printf("NAND分区加载失败\n");
		MessageBox(L"显示NAND失败");
		CloseHandle(h_NandPart);
		CloseHandle(h_openStore);
		return;
	}

	CloseHandle(h_NandPart);
	CloseHandle(h_openStore);
	MessageBox(L"显示NAND成功");

}