GetOpenFileName错误 [英] GetOpenFileName bug

查看:123
本文介绍了GetOpenFileName错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

带标志的GetOpenFileName

OFN_ALLOWMULTISELECT
如果字符数超过29700个字符,
将创建错误消息。

如果你分配了我并不重要足够的空间。它只会使用第一个32768

TCHAR。


错误信息是找不到文件,显示部分文件名。


BTW MS的错误报告网站的URL是什么。


Rajko。


PS是否有针对此错误的解决方法?

GetOpenFileName with flag
OFN_ALLOWMULTISELECT
will create error message if number of characters exceeds 29700 characters.
I does not matter if you alocated enough space. It will use only first 32768
TCHARs.

Error message is file not found, and partial file name is displayed.

BTW what is the URL of error reporting site at MS.

Rajko.

PS Is there workaround for this bug?

推荐答案

> GetOpenFileName带有标志
>GetOpenFileName with flag
OFN_ALLOWMULTISELECT
将创建错误消息,如果数量为字符超过29700个字符。
如果你提供足够的空间,我无所谓。它只会使用第一个32768
TCHAR。
OFN_ALLOWMULTISELECT
will create error message if number of characters exceeds 29700 characters.
I does not matter if you alocated enough space. It will use only first 32768
TCHARs.




您是否有一个简短的代码示例来说明问题?


这会显示哪些操作系统?


Dave

-

MVP VC ++ FAQ:< a rel =nofollowhref =http://www.mvps.org/vcfaqtarget =_ blank> http://www.mvps.org/vcfaq


如果你使用multiselection并选择一个目录中的所有文件

,其中大约有500个左右,它会抛出异常Too many files或者

类似的东西。

当试图读取图像序列进行分析时,这是用途......

等......


JB


" David Lowndes" <哒**** @ example.invalid>在消息中写道

新闻:6o ******************************** @ 4ax.com ...
And if you use multiselection and select all the files in one directory
where there are about 500 or so, it throws an exception "Too many files" or
something similar.
This is uselss when trying to read in sequences of images for analysis
etc...

JB

"David Lowndes" <da****@example.invalid> wrote in message
news:6o********************************@4ax.com...
带有标志的GetOpenFileName
OFN_ALLOWMULTISELECT
如果字符数超过29700
个字符,则会创建错误消息。我没有如果你给了足够的空间,那就重要了。它将只使用第一个
32768TCHAR。
GetOpenFileName with flag
OFN_ALLOWMULTISELECT
will create error message if number of characters exceeds 29700 characters.I does not matter if you alocated enough space. It will use only first 32768TCHARs.



你有一个简短的代码示例来说明问题吗?

哪个操作系统可以这个出现了吗?

Dave
-
MVP VC ++ FAQ: http://www.mvps.org/vcfaq



这是我的应用程序中的代码:

#define MAX_FILES_IN_OPEN_DIALOG 2000

.....

void CMRenameDialog :: SelectFiles(){

OPENFILENAME ofn;

TCHAR FileName [MAX_PATH] = {0},* FileDir;

unsigned long FileNameOffset = 0;

DWORD szFileDir = MAX_FILES_IN_OPEN_DIALOG * MAX_PATH;

FileDir =(TCHAR *)malloc(szFileDir * sizeof(TCHAR));

FileDir [0] = NULL;


ofn.lStructSize = sizeof(ofn);

ofn.hwndOwner = m_hWnd;

ofn.h.hstst = NULL;

ofn.lpstrFilter = _T (所有文件(*。*)\ 0 *。* \ 0 \ 0 ;);

ofn.lpstrCustomFilter = NULL;

ofn.nMaxCustFilter = 0;

ofn.lpstrFile = FileDir;

ofn.nMaxFile = szFileDir; //在TCHARS

ofn.lpstrFileTitle = FileName;

ofn.nMaxFileTitle = sizeof(FileName)/ sizeof(TCHAR);

ofn。 lpstrInitialDir = m_SelectedFileDir;

ofn.lpstrTitle = WINDOWS_OPEN_DIALOG_TITLE;

ofn.Flags = OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_FILEMUSTEXIST |

OFN_LONGNAMES;

ofn.nFileOffset = 0;

ofn.lpstrDefExt = NULL;

ofn。 lpfnHook = NULL;

ofn.lpTemplateName = NULL;


if(GetOpenFileName(& ofn)){< ---这是这里的行执行

stoped

.....

我创建了dir C:\ Temp \ Test 1000包含1000个文件:

TEMP_TEST 1000_COPY(1)OF EMPTY.TXT

TEMP_TEST 1000_COPY(2)EMPTY.TXT

....

TEMP_TEST 1000_COPY(801)OF EMPTY.TXT

TEMP_TEST 1000_COPY(802)OF EMPTY.TXT

TEMP_TEST 1000_COPY(803)OF EMPTY.TXT

....

TEMP_TEST 1000_COPY(999)OF EMPTY.TXT

TEMP_TEST 1000_COPY(1000)OF EMPTY.TXT


打开对话框出现,我选择所有1000个文件,然后消息框显示

以下文字:

TEMP_TEST 1000_COPY(802)OF E

找不到文件。

请验证是否正确文件名已经给出了。

就是这样,Rajko。


" David Lowndes" <哒**** @ example.invalid>在消息中写道

新闻:6o ******************************** @ 4ax.com ...
This is code from my app:
#define MAX_FILES_IN_OPEN_DIALOG 2000
.....
void CMRenameDialog::SelectFiles() {
OPENFILENAME ofn;
TCHAR FileName[MAX_PATH]={0}, *FileDir;
unsigned long FileNameOffset=0;
DWORD szFileDir = MAX_FILES_IN_OPEN_DIALOG*MAX_PATH;
FileDir = (TCHAR *)malloc(szFileDir*sizeof(TCHAR));
FileDir[0] = NULL;

ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = m_hWnd;
ofn.hInstance = NULL;
ofn.lpstrFilter = _T("All Files(*.*)\0*.*\0\0");
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.lpstrFile = FileDir;
ofn.nMaxFile = szFileDir; // in TCHARS
ofn.lpstrFileTitle = FileName;
ofn.nMaxFileTitle = sizeof(FileName)/sizeof(TCHAR);
ofn.lpstrInitialDir = m_SelectedFileDir;
ofn.lpstrTitle = WINDOWS_OPEN_DIALOG_TITLE;
ofn.Flags = OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_FILEMUSTEXIST |
OFN_LONGNAMES;
ofn.nFileOffset = 0;
ofn.lpstrDefExt = NULL;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;

if (GetOpenFileName(&ofn)) { <--- this is the line where execution
stoped
.....
I created dir C:\Temp\Test 1000 which containde 1000 files:
TEMP_TEST 1000_COPY (1) OF EMPTY.TXT
TEMP_TEST 1000_COPY (2) OF EMPTY.TXT
....
TEMP_TEST 1000_COPY (801) OF EMPTY.TXT
TEMP_TEST 1000_COPY (802) OF EMPTY.TXT
TEMP_TEST 1000_COPY (803) OF EMPTY.TXT
....
TEMP_TEST 1000_COPY (999) OF EMPTY.TXT
TEMP_TEST 1000_COPY (1000) OF EMPTY.TXT

open dialog appears and I select all 1000 files, then MessageBox appear with
following text:
TEMP_TEST 1000_COPY (802) OF E
File not found.
Please verify the correct file name was given.
That''s it, Rajko.


"David Lowndes" <da****@example.invalid> wrote in message
news:6o********************************@4ax.com...
带有标志的GetOpenFileName
OFN_ALLOWMULTISELECT
如果字符数超过29700
个字符,则会创建错误消息。我没有如果你给了足够的空间,那就重要了。它将只使用第一个
32768TCHAR。
GetOpenFileName with flag
OFN_ALLOWMULTISELECT
will create error message if number of characters exceeds 29700 characters.I does not matter if you alocated enough space. It will use only first 32768TCHARs.



你有一个简短的代码示例来说明问题吗?

哪个操作系统可以这个出现了吗?

Dave
-
MVP VC ++ FAQ: http://www.mvps.org/vcfaq






这篇关于GetOpenFileName错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆