|
|
If the number of files you select is causing it to fail, then your buffer is probably too small. With a buffer of 4096 and 160 files, that's only 25 characters per file.
Acccording to MSDN:
If the buffer is too small, the function returns FALSE and the CommDlgExtendedError function returns FNERR_BUFFERTOOSMALL. In this case, the first two bytes of the lpstrFile buffer contain the required size, in bytes or characters.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
I am trying with VS 2008 under Vista and even if buffer is small I do not get FNERR_BUFFERTOOSMALL. CFileDialog simply return files it can with the given buffer. I couldn't find anything specific to this in MSDN.
-Saurabh
|
|
|
|
|
I am using VS 2008 on Vista and it works even with 1000 files.
-Saurabh
|
|
|
|
|
You can call
DWORD error = CommDlgExtendedError();
to find out what exactly is the problem.
-Saurabh
|
|
|
|
|
Hi,
your code works fine for me also.
thanks,
Nitheesh
|
|
|
|
|
pther wrote: What is the problem with it?
How are we to know? What problem(s) are you seeing?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I had the same problem once with selecting *lots* of files, set "pc" to something like 64000.
"It is better to remain silent and be thought a fool, than to open your mouth and remove all doubt."
--Groucho Marx
|
|
|
|
|
I am trying to receive asynchronous sockets via udp but I am mostly getting WSAEWOULDBLOCK error . I anyone help me solving this problem
WSADATA wsaData;
int error = WSAStartup(0x202,&wsaData);
if(error)
return FALSE;
if(wsaData.wVersion != 0x202)
{
WSACleanup();
return FALSE;
}
m_UdpSock=(SOCKET)WSASocket(AF_INET,SOCK_DGRAM,0,NULL,NULL,0);
if(m_UdpSock==INVALID_SOCKET)
return FALSE;
sockaddr_in sockAddrServer;
sockAddrServer.sin_family=AF_INET;
sockAddrServer.sin_port=htons(port_data);
sockAddrServer.sin_addr.s_addr=INADDR_ANY;
// Bind socket to listener address
if(bind(m_UdpSock,(SOCKADDR*)&sockAddrServer,sizeof(sockaddr_in))==SOCKET_ERROR)
{
int y=WSAGetLastError();
printf("Unable to bind socket\n");
return FALSE;
}
// Create WinSock Event object
WSAEVENT eventWinsock=(WSAEVENT)WSACreateEvent();
if(eventWinsock==WSA_INVALID_EVENT)
{
printf("Unable to create winsock event\n");
return FALSE;
}
// Signal WinSock Event on receive packet
if(WSAEventSelect(m_UdpSock,eventWinsock,FD_READ)!=NOERROR)
{
printf("Unable to connect event to socket\n");
return FALSE;
}
//long length=50000;
// m_Thread=new CManager((LPVOID)this);
// m_Thread->CreateThread();
bool occurance=true;
while(m_abort)
{
Recvbuf=new char[BUFFER_SIZE];
TRACE("Before Receive Data\n");
//if(WaitForSingleObject(eventWinsock,INFINITE)== WAIT_OBJECT_0)
if(WaitForSingleObject(eventWinsock,INFINITE)== WAIT_OBJECT_0)
{
sockaddr_in sockAddrRecv;
int nSockAddrSize=sizeof(sockaddr_in);
// Packet received
EnterCriticalSection(&m_cs);
int nErr=recvfrom(m_UdpSock,Recvbuf,BUFFER_SIZE,0,(sockaddr*)&sockAddrRecv,&nSockAddrSize);
LeaveCriticalSection(&m_cs);
TRACE("Receive data\n");
if(nErr==SOCKET_ERROR)
{
TRACE("nErr %d\n",nErr);
nErr=WSAGetLastError();
if(nErr==WSAEWOULDBLOCK)
{
WSAEventSelect(m_UdpSock,eventWinsock,FD_READ);
WSANETWORKEVENTS wsevents;
WSAEnumNetworkEvents(m_UdpSock,eventWinsock,&wsevents);
DWORD dwEventId = WaitForSingleObject(eventWinsock,3000);
if(dwEventId == WAIT_TIMEOUT)
continue;
continue;
}
else
{
WSAEventSelect(m_UdpSock,eventWinsock,FD_READ);
WSANETWORKEVENTS wsevents;
WSAEnumNetworkEvents(m_UdpSock,eventWinsock,&wsevents);
DWORD dwEventId = WaitForSingleObject(eventWinsock,3000);
if(dwEventId == WAIT_TIMEOUT)
continue;
continue;
}
}
else
{
TRACE("Receive Data Size %d\n",nErr);
BYTE init=Recvbuf[0];
//EnQueue
m_Queue.SetAt(index,Recvbuf);
m_PacketSize.SetAt(index,nErr);
index++;
if(occurance)
{
DWORD dwThreadId1;
m_DeQueueThread=CreateThread(NULL,0,&Dequeue,this,CREATE_SUSPENDED,&dwThreadId1);
ResumeThread(m_DeQueueThread);
m_play->InitState=m_dequeue=true;
occurance=false;
}
}
}
}
|
|
|
|
|
Has your code changed since I answered this a couple days ago?
If you post code wrapped in pre tags, most of us would be much more
inclined to read it.
It appears you still have the same problem as a couple days ago....
the code is wrong.
You're not using the event properly.
You can simplify your code to something like this (pseudocode):
create/init/connect the socket
WSACreateEvent
WSAEventSelect
while(m_abort)
{
WaitForEvent
WSAEnumNetworkEvents (this will reset the event)
if read event
{
read a datagram, or loop reading datagrams until you get a WSAEWOULDBLOCK error
}
}
You also probably want another event so you have a way to exit the loop if no data is received...
create/init/connect the socket
create an abort event
WSACreateEvent
WSAEventSelect
while(m_abort)
{
Wait For socket or abort Event (WaitForMultipleObjects)
if abort event
{
break;
}
else
{
WSAEnumNetworkEvents (this will reset the socket event)
if read event
{
read a datagram, or loop reading datagrams until you get a WSAEWOULDBLOCK error
}
}
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What does the following code available in .h files signify ?
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
|
|
|
|
|
#pragma once directive specifies that the file will be included only once by the compiler when compiling a source code file.
This can reduce build times as the compiler will not open and read the file after the first #include of the module.
Mukesh Kumar
Software Engineer
|
|
|
|
|
_MSC_VER defines the major and minor versions of the compiler. For microsoft visual c++.net its value is 1300 i.e. version 13 and for vc 6.0 its value is 1000.
#pragma once specifies that the file will be included only once by the compiler in a build.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
So, does that mean for vc 6.0 (with version == 1300), #pragma once is not executed ? If yes, does that mean the file will be compiled every time we build it ?
|
|
|
|
|
Shilpi Boosar wrote: for vc 6.0 its value is 1000.
Are you sure? I just checked and it returned 1200
BTW I have sp5 installed. Will that change the compiler version?
|
|
|
|
|
Sorry. For vc 6.0 (version is >= 1000).
So everything is fine. Thanks for the discussion.
|
|
|
|
|
Yes it is 1200 .
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
The _MSC_VER macro will have one of the following values depending upon the particular Microsoft compiler: Compiler _MSC_VER value
-------- --------------
C Compiler version 6.0 600
C/C++ compiler version 7.0 700
Visual C++, Windows, version 1.0 800
Visual C++, 32-bit, version 1.0 800
Visual C++, Windows, version 2.0 900
Visual C++, 32-bit, version 2.x 900
Visual C++, 32-bit, version 4.0 1000
Visual C++, 32-bit, version 5.0 1100
Visual C++, 32-bit, version 6.0 1200
.....
from http://support.microsoft.com/kb/65472[^]
|
|
|
|
|
To add to Mukesh's reply:
It tells the compiler that there are no side effect from multiple inclusions, i.e. including it twice has the same effect as including it once.
It is similar to include guards (#infdef foo_h #define foo_h ... #endif), but is a bt more strict and offers better performance: the compiler does not need to open the file again, and parse the entire text.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
SherTeks wrote: #if _MSC_VER > 1000
See here.
SherTeks wrote: #pragma once
See here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello all,
I am trying to make a progress bar in a dialog box. What i want to do is as soon as dialog box is displayed the progress bar should start running.
i am writing code for running progressbar in OnInitDialog so its not showing progress bar runnning.
How can i do it?
Thanks in advance
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
ThatsMe. wrote: i am writing code for running progressbar in OnInitDialog
Can you show the code?
|
|
|
|
|
code is like....
this is my OnInitDialog() function
BOOL CExeCreatorDlg::OnInitDialog()
{
CreatingExe(i);
return TRUE;
}
and in this function i am stepping up the progress bar and setting its position....
obviously i know untill dialog box return value it'll not be created and how could progress bar show up.... so where i should call my function i am not getting this
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
If you continuously step the progress bar inside a loop, it will not get a chance to paint. So what you have to do is Create a thread, and call CreatingExe() from that thread.
If you are not doing any other processing, you can and a timer and set the progree bar position from that function.
|
|
|
|
|
Hi,
SetUp timer in OnInitDilag like this
<br />
BOOL CExeCreatorDlg::OnInitDialog()<br />
{<br />
SetTimer(this->m_hWnd, 1,1000,0);<br />
}<br />
and In OnTimer Call you function CreatingExe(i);<br />
void CExeCreatorDlg::onTimer(UINT Id)<br />
{<br />
CreatingExe(i);<br />
}<br />
<br />
thanks<br />
Nitheesh<br />
<br />
<br />
<br />
|
|
|
|