|
ns wrote:
I need 2 columns to always be #1 and 2...
Then add them after all other columns have been added.
ns wrote:
...but it acted the same as:
Probably because they are both the same! Notice the placement of nsub . The parameters passed to InsertColumn() are the same, while the condition in the if statement is different.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi, i'm trying to write a multithreaded TCP server and it seemed to work ok now but suddenly i got this assertion error! The thing is, to test the server i connect with the windows 98 telnet application to my server. The clienthandler threads of my server continously check with select() if there is something to read on the socket. This gives me the oportunity to also check if the socket handle is not INVALID_SOCKET, since we might set it to this from somewhere else if we would like to "boot" the client and make sure the thread terminates. I get the assertion error in a number of particular cases, these are the two most common:
When i connect via telnet, type some text, then connect another one, also type some text, and then i close the first one without disconnecting properly, also the server does not see it is disconnected.
Or, when i connect, type some text, close telnet without disconnecting, and reconnect.
After these two situations it always gives me the error "Debug Assertion failed" in dbgheap.c.
This is part of my code:
DWORD WINAPI ClientHandler(void* prms)
{
ClientInfo * clinfo = (struct ClientInfo*)prms;
SOCKET sd = (SOCKET)clinfo->SocketHandle;
char buffer[1024];
int nRead = 0;
BOOL abort = FALSE;
do
{
if(sd!=INVALID_SOCKET && IsSocketReadyToRead(sd,50))
{
nRead = recv(sd, buffer, sizeof(buffer), 0);
if(nRead==0)
{
abort = TRUE;
}
}
}
while(!abort);
RemoveConnection(sd);
return 0;
}
ClientInfo is just a struct with some information about each client (socket handle, thread handle, etc..)
This is what IsSocketReadyToRead() looks like:
BOOL IsSocketReadyToRead(SOCKET s, int timeout)
{
int retval;
fd_set* socketset;
socketset = new fd_set;
FD_ZERO(socketset);
FD_SET(s, socketset);
if( timeout!=0 )
{
struct timeval time;
memset(&time,0,sizeof(struct timeval));
time.tv_sec = 0;
time.tv_usec = (long)timeout;
retval = select( 0, socketset, NULL, NULL, &time );
}
else
{
struct timeval time = { 0, 0 };
retval = select( 0, socketset, NULL, NULL, &time );
}
delete socketset;
switch(retval)
{
case 1:
return TRUE;
break;
case 0:
return FALSE;
break;
case SOCKET_ERROR:
return FALSE;
break;
default:
return FALSE;
}
}
The RemoveConnection function does not matter seeings in neither of the situations it is called.
Does anyone have any idea what might be causing this?
Oh yes btw, i also, at other times, in the same situation, did not get the assertion error, but a memory error where it gave me that "the memory could not be written." and the contents of a pointer. But i don't know if its my app or the underlying framework. Thanks for any help, if you would like to see more code, just ask.
Kuniva
--------------------------------------------
|
|
|
|
|
I'm attempting to load a .jpg file into an MFC project which uses the CRichEditView class. I can use InsertFileAsObject to load a bitmap fine, but when I attempt to load a jpg file it draws a box with the filename instead of embedding the picture itself. Any suggestions?
|
|
|
|
|
It has to do with what program is associated with jpgs. If the associated program does provide OLE containers then all you get is an icon. You can either associate it to a differnt program (IE comes to mind) or convert the jpg to a bitmap and then insert.
--
Joel Lucsy
|
|
|
|
|
Hello all
I coded a window service which creates a lot of tmp files in the course of its operation. I wanted to delete these files once service is stopped. I'm using the following code to do so in destructor function ...
SHFILEOPSTRUCT fs ;
char buff[255];
char tmp[]="\\*\0\0";
sprintf(buff,"%s%s",sWorkingDir,tmp);
int len=strlen(buff);
buff[++len]=NULL;
buff[++len]=NULL;
fs.hwnd = NULL;
fs.wFunc = FO_DELETE ;
fs.pFrom = ( LPCSTR ) buff ;
fs.pTo = NULL;
fs.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_SILENT;
if(SHFileOperation ( &fs ) ==0)
WriteLogData('I',5,"DST","Successfully deleted tmp files");
else
WriteLogData('E',5,"DST","Unable to delete tmp files");
but the above code is not working within windows service. When I used the same code in a standalone application it is working. When I use GetLastError() in service I'm getting value 6( stands for INVALID_HANDLE). Can any one help me in this
Thanks for your help
Hari.
|
|
|
|
|
Could it be that SHFileOperation is considered "interactive" and your service is not allowed to interact with the desktop?
--
Talk to the hand!
|
|
|
|
|
Hello Jorgen
I already selected "interact with desktop" option from service control window.
but it's not working ..
Thanks for the help
Hari.
|
|
|
|
|
Have you also tried running the service as different users? I know the LSA (Local System Account) can be tricky. Especially if you're copying files to/from a non-local drive/shares. IIRC, the LSA account can only operate on local/physical devices.
--
Talk to the hand!
|
|
|
|
|
hi
how can i Transfer a PictureBox picture to an array of bytes?
thanks
|
|
|
|
|
I'm using vc++ 6.0,MFC and the CDao classes to open up access databases because of the better performance over ODBC. But when I try to open an Access 2000 db, it can't do it. I assume this is because the Jet engine it is using is 3.x. Is there a way to set which jet engine is used???
Thanks
|
|
|
|
|
rfraser wrote:
Is there a way to set which jet engine is used???
Yes there is.
This is a known MFC bug. The workaround is discussed
Here[^]
I Dream of Absolute Zero
|
|
|
|
|
Please note that Microsoft really are trying to kill off DAO. If you want to future proof your application I would reccommend switching to ADO (there are some C++ wrapper classes for this).
|
|
|
|
|
This is true.
Although, to be on rfraser's side, DAO *is* much more faster and efficient than ADO due to the fact thats its inherently closer to the native JET engine. I have been using ADO, over DAO for a while now and know of its scalability. But the downside is that you lose the data access speed that DAO is so good at. Switching to ADO, no matter what the speed depreciation, is the way forward. If I remember correctly, Microsoft has stopped support for the JET engine as of V2.7 of the ADO distribution files. This is to promote the MSDE engine; a localised, 'baby' version of the SQL Server database system.
My advice is to start out on your db adventure with the CDAO* classes then quickly move on to ADO for real world, scalable applications.
I Dream of Absolute Zero
|
|
|
|
|
Hi , just an question from a novice like me :
how to use #import in c programme ?
not c++ is there an directive like it for c ?
it's for use ADO in a c program
thank you
Adel
that which hesitates is lost.
that which hesitates is lost.
|
|
|
|
|
Hy everybody!
Can someone help me?
I have an Window with a RichEditCtrl on it,
and when it is minimized, and some text is inserted, the RichEdit just don't scroll, even doing LineScroll(int).
anybody haves any idea?
cheers!
|
|
|
|
|
Hi.
I try to find a way to capture and manage starting of all application under windows NT serie (NT4.0, 2K, XP).
I would like manage a log file and save into it when user start some specific applications.
- The first way is by using a new gina.dll with fonction like WlxActivateUserShell (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/security/wlxactivateusershell.asp)
But this solution is so constraining to use it.
- Second way using a Hook procedure. I try to capture the WH_SHELL type. But the hook capture only event from the window which manage the hook.
I install two hooks : one for mouse event and one for Shell event for all threads (dwThreadId=0 when calling SetWindowsHookEx function)
With my application i capture all mouse events for every process and windows. But only shell events for my application, for the other windows it's appear no shell events capture.
If some one have some cool ideas. Thanx
|
|
|
|
|
You might want to look at various investigations of PsSetCreateProcessNotifyRoutine, including this [^] one.
The method of user mode notification is the crucial element in this and similar apps. Test under stress.
|
|
|
|
|
How does PsSetCreateProcessNotifyRoutine() sound?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Third way:
Change the default value of
HKEY_CLASSES_ROOT\exefile\shell\open\command
to
"c:\\pathtoyourfile.exe" %*
Your app gets called for every dblclk on ANY exe.
Then ShellExecute the original app (from command line).
Peter Molnar
|
|
|
|
|
Does anyone know if BLOBs can be inserted into an Oracle database, via a VC++ client, by creating and executing a SQL insert statement. I seem to recall reading somewhere that BLOBs can only be inserted via calling a stored procedure in the Oracle dB.
|
|
|
|
|
We used ADO to connect to our Oracle database. ADO can get/set BLOB data by using a SAFEARRAY attached to a variant. I can provide more detail if desired.
--
Joel Lucsy
|
|
|
|
|
I would appreciate any detail you can provide. This is the first database task I've worked on. -Thanks!
|
|
|
|
|
First, we used the class found at http://www.codeproject.com/database/caaadoclass1.asp[^]
Then we did something like to add to the database:
<br />
CADODatabase db;<br />
CADORecordset rs;<br />
COleSafeArray sa;<br />
void *buf;<br />
_variant_t v;<br />
sa.CreateOneDim( VT_UI1, );<br />
sa.AccessData( &buf );<br />
<br />
sa.UnaccessData();<br />
v = sa.Detach();<br />
db.Open( "<some connection string>" );<br />
rs.Open( db.GetActiveConnection(), "select * from table", CADORecordset::openQuery );<br />
rs.Edit();<br />
rs.SetFieldValue( "blobfield", v );<br />
rs.Update();<br />
rs.Close();<br />
db.Close();<br />
The code to read is similar. Let me know if you need that also.
--
Joel Lucsy
|
|
|
|
|
Hi all,
I'm doing a C++ programming on mobile agents...and I've been trying to find a way to get the CPU and memory usage using C++, so exatly like what we can get from Windows Task Manager.
I've looked into GetSystemInfo() and GetProcessMemoryInfo(), but there's not much useful information that I can get from them...
Can sombody help me? Thank you very much
Clara~
|
|
|
|
|
You might want to look at CreateToolhelp32Snapshot , Process32First and Process32Next .
<EDIT>Ooops - my bad - was thinking of the Processes tab... </EDIT>
|
|
|
|