如何使用诺基亚 API 获取手机驱动器的大小(免费、总计)?
我想获取手机驱动器的大小。 我正在使用“Nokia-PC-Connectivity”。关于文件系统 API,我在名为 CONA_Folder_Info 的 CONADifinition 函数上找到,但该函数不支持 FreeSize 和 Total Size,但有 CONA_Folder.Info2 及其实例支持这些变量。
但是当我按如下方式使用 CONA_Folder.Info2 时:
CONADefinitions.CONAPI_FOLDER_INFO2 FolderInfo;
int iResult = 0;// Allocate memory for buffer
IntPtr Buffer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CONADefinitions.CONAPI_FOLDER_INFO2)));
iResult = CONAFileSystem.CONAFindNextFolder(hFindHandle, Buffer);
while (iResult == PCCSErrors.CONA_OK )
{
FolderInfo = (CONADefinitions.CONAPI_FOLDER_INFO2)Marshal.PtrToStructure(Buffer, typeof(CONADefinitions.CONAPI_FOLDER_INFO2));
if (FolderInfo.pstrName[0].ToString() != "C" && level == 0)
{
}
我收到此异常:
检测到 FatalExecutionEngineError 消息:运行时遇到了 致命错误。 错误的地址 位于 0x7a0ba769,线程 0x1278。 错误代码为0xc0000005。 这 错误可能是 CLR 中的错误或 不安全或不可验证的部分 用户代码。 此的常见来源 bug 包括用户编组错误 COM 互操作或 PInvoke,这可能 损坏堆栈。
注意:我使用S60软件平台。 应用语言是C#。
如需更多解释请询问我。
I want to get the size of the phone drive.
I'm using "Nokia-PC-Connectivity"., and with respect to File System API I found on CONADifinition function called CONA_Folder_Info but this function doens't support FreeSize and Total Size but there is CONA_Folder.Info2 and its instance support these variables.
But when I used CONA_Folder.Info2 as follows:
CONADefinitions.CONAPI_FOLDER_INFO2 FolderInfo;
int iResult = 0;// Allocate memory for buffer
IntPtr Buffer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CONADefinitions.CONAPI_FOLDER_INFO2)));
iResult = CONAFileSystem.CONAFindNextFolder(hFindHandle, Buffer);
while (iResult == PCCSErrors.CONA_OK )
{
FolderInfo = (CONADefinitions.CONAPI_FOLDER_INFO2)Marshal.PtrToStructure(Buffer, typeof(CONADefinitions.CONAPI_FOLDER_INFO2));
if (FolderInfo.pstrName[0].ToString() != "C" && level == 0)
{
}
I get this exception:
FatalExecutionEngineError was detected
Message: The runtime has encountered a
fatal error. The address of the error
was at 0x7a0ba769, on thread 0x1278.
The error code is 0xc0000005. This
error may be a bug in the CLR or in
the unsafe or non-verifiable portions
of user code. Common sources of this
bug include user marshaling errors for
COM-interop or PInvoke, which may
corrupt the stack.
Note: I use the S60 software platform. Application language is C#.
For more explanations please ask me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您尝试将缓冲区中的数据转换为与 CONAFileSystem.CONAFindNextFolder 最初创建的结构类型不同的结构类型时,出现异常是正确的。
您试图将 CONADefinitions.CONAPI_FOLDER_INFO 类型的数据结构强制转换为 CONADefinitions.CONAPI_FOLDER_INFO2 类型的结构。 它们几乎肯定具有不同的长度等等,因此这种方法极不可能起作用。
根据 Symbian 操作系统上的 C++ 开发经验,诺基亚可能在这里使用的模式是他们随后开发了更新版本的 API,因此创建了更新版本的 CONADefinitions.CONAPI_FOLDER_INFO 结构(即 CONADefinitions.CONAPI_FOLDER_INFO2) )。
假设这是正确的,则有 3 种可能性:
1) 第一个函数有一个枚举参数,它指定要创建哪个版本的输出结构。
2)有一个新函数返回新结构,例如 CONAFileSystem.CONAFindFirstFolder2、CONAFileSystem.CONAFindNextFolder2
3) 诺基亚已在内部开发了新版本,但尚未公开发布。
It is correct that you get the exception when you try and convert the data in the buffer to a different type of structure than was originally created by CONAFileSystem.CONAFindNextFolder.
You are trying to force a data structure of type CONADefinitions.CONAPI_FOLDER_INFO into a structure of type CONADefinitions.CONAPI_FOLDER_INFO2. They almost certainly have different lengths and so on so its extremely unlikely this method would ever work.
From experience with C++ development on the Symbian OS, the pattern Nokia are likely to be using here is one where they have subsequently developed a newer version of the API and so have created a newer version of the CONADefinitions.CONAPI_FOLDER_INFO structure (i.e. CONADefinitions.CONAPI_FOLDER_INFO2).
Assuming this is correct there are 3 likelihoods:
1) There is an enum parameter to the first function which specifies which version of the output structure is to be created.
2) There is a new function which returns the new structure e.g. CONAFileSystem.CONAFindFirstFolder2, CONAFileSystem.CONAFindNextFolder2
3) Nokia have developed the new version internally but not yet released it publicly.
我对诺基亚 API 一无所知,但总的来说,我看到以下内容:
I don't know anything about the Nokia API, but in general I see the following: