GetOpenFileName bug

  • Thread starter Thread starter Rajko
  • Start date Start date
R

Rajko

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 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.

Do you have a short code sample that illustrates the problem?

Which operating system(s) does this show up on?

Dave
 
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
 
I didn't see message "Too many files" but I tested with different file
names.
First I used file name:
TEMP_TEST 1000_COPY (1) OF EMPTY.TXT
TEMP_TEST 1000_COPY (2) OF EMPTY.TXT
....

error was at 802

then I put one more char in front all files, follows:
1TEMP_TEST 1000_COPY (1) OF EMPTY.TXT
1TEMP_TEST 1000_COPY (2) OF EMPTY.TXT
....

now error was at 783, but not at 802 so I calculated:
801*37+31 = 29668 TCHARs
or
782*38+26 = 29742 TCHARs

well it is about 32768 boundry for signed integer !!!

Rajko.
 
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.
 
This is code from my app:

.... and the operating systems you've tested against?

Dave
 
XP pro v2002 SP1, and most of SP2.
MS Dev Env 2003 v7.1.3088
..NET Framework v1.1.4322

Just this one, for now.

Rajko
 
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
...
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.

OK, I can reproduce the same error message when I click OK after
selecting a large number of files.

I note that the documentation for GetOpenFileName says this:

"Note, when selecting multiple files, the total character limit for
the file names depends on the operating system and the version of the
function.

Windows 2000/XP: (ANSI) 32k limit, (Unicode) no restriction "

but according to these results, this isn't correct because I get
exactly the same results with an ANSI and Unicode build.

I'm not aware of any work-around - if you don't get any other
suggestions here I suggest that you contact MS PSS and give them a
minimal sample in order to reproduce the problem. I'll try to pass
this on to MS myself, but it may take some time before I get an
answer, so I recommend that you ring PSS - please let us know the
outcome by posting back if you do so.

Dave
 
OK, I can reproduce the same error message when I click OK after
selecting a large number of files.

I note that the documentation for GetOpenFileName says this:

"Note, when selecting multiple files, the total character limit for
the file names depends on the operating system and the version of the
function.

Windows 2000/XP: (ANSI) 32k limit, (Unicode) no restriction "

but according to these results, this isn't correct because I get
exactly the same results with an ANSI and Unicode build.

I'm not aware of any work-around - if you don't get any other
suggestions here I suggest that you contact MS PSS and give them a
minimal sample in order to reproduce the problem. I'll try to pass
this on to MS myself, but it may take some time before I get an
answer, so I recommend that you ring PSS - please let us know the
outcome by posting back if you do so.

Dave


I used Unicode version, but not explicitly like GetOpenFileNameW.
Compiler take care of it as far as I know.

Could you tell me in more detail how and where to contact MS PSS?
thx

Rajko
 
Could you tell me in more detail how and where to contact MS PSS?

I can't tell you specifically because it depends on your location and
whether your company has any special support options. Try
http://support.microsoft.com and the "Contact Us" link. That should
get you to your local MS support options (it does for me in the UK).

Dave
 
OK. Thanks Dave.
BTW I'm form Croatia.

Rajko.

David Lowndes said:
I can't tell you specifically because it depends on your location and
whether your company has any special support options. Try
http://support.microsoft.com and the "Contact Us" link. That should
get you to your local MS support options (it does for me in the UK).

Dave
 
I can't find it on support!!!!
I realy tried, but nothing one hour ow the web and nothing!!!
I tried switching to US page and still nothing.
Can you tell me your report a bug page, I mean UK page.
I could switch to your page and then send it.

Thx, Rajko.
PS And i thought it would be large button so you cant miss it! :-)
They hide it from me very well.
BTW I never reported a bug till now.
 
I can't find it on support!!!!
I realy tried, but nothing one hour ow the web and nothing!!!
I tried switching to US page and still nothing.
Can you tell me your report a bug page, I mean UK page.
I could switch to your page and then send it.

http://support.microsoft.com/default.aspx?scid=fh;[ln];CNTACTMS

and then to:

http://support.microsoft.com/default.aspx?scid=fh;en-gb;telephonems

but all the information is UK specific, so I don't see that it'll be
any help to you.

Dave
 
I see. So you contacted them over telephone.
I thought there is online form for submiting bugs.

I found this one:
http://support.microsoft.com/default.aspx?scid=/support/visualc/report/default.asp
but it doesn't work!!
When I submit page error occurs:
An error occurred rendering the requested content.
URL:
http://support.microsoft.com/support/visualc/report/vcsubmit.asp?SD=GN&LN=HR

I called mine support and they never heard of such thing as bug report.
At the end they gave me following e-mail to contact them:
(e-mail address removed) with subject "hotline".
I do not need to say more, don't I? If this is bug report centar then I'm
turtle.
So, I was disappointed and don't know what to do.

Rajko.


David Lowndes said:
I can't find it on support!!!!
I realy tried, but nothing one hour ow the web and nothing!!!
I tried switching to US page and still nothing.
Can you tell me your report a bug page, I mean UK page.
I could switch to your page and then send it.

http://support.microsoft.com/default.aspx?scid=fh;[ln];CNTACTMS

and then to:

http://support.microsoft.com/default.aspx?scid=fh;en-gb;telephonems

but all the information is UK specific, so I don't see that it'll be
any help to you.

Dave
 
Hi Rajko,

Using the phone is the only method that works. If you call again and cannot
get the support engineer to give you the support you need, ask them to
contact me (Ronald Laeremans, Group Program Manager, Visual C++). And please
send me an email (mangle my posting alias in the obvious way) with their
exact name so I can follow up.

Sorry for the runaround you got.

Thanks.

Ronald Laeremans

Rajko said:
I see. So you contacted them over telephone.
I thought there is online form for submiting bugs.

I found this one:
http://support.microsoft.com/default.aspx?scid=/support/visualc/report/default.asp
but it doesn't work!!
When I submit page error occurs:
An error occurred rendering the requested content.
URL:
http://support.microsoft.com/support/visualc/report/vcsubmit.asp?SD=GN&LN=HR

I called mine support and they never heard of such thing as bug report.
At the end they gave me following e-mail to contact them:
(e-mail address removed) with subject "hotline".
I do not need to say more, don't I? If this is bug report centar then I'm
turtle.
So, I was disappointed and don't know what to do.

Rajko.


David Lowndes said:
I can't find it on support!!!!
I realy tried, but nothing one hour ow the web and nothing!!!
I tried switching to US page and still nothing.
Can you tell me your report a bug page, I mean UK page.
I could switch to your page and then send it.

http://support.microsoft.com/default.aspx?scid=fh;[ln];CNTACTMS

and then to:

http://support.microsoft.com/default.aspx?scid=fh;en-gb;telephonems

but all the information is UK specific, so I don't see that it'll be
any help to you.

Dave
 
Back
Top