|
This is a wild guess, but... Are you sure the code of your class is being linked? Maybe the .cpp has been moved to a static library and the linker is stripping away the object code of the class because it is not directly referenced in the program.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your kind suggestion, but, the code is accessed directly, and won't run into problems like this... but thankyou for trying
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Another wild guess Have you been playing around with the schema number in the IMPLEMENT_SERIAL macro? There's an MSDN article that says something about a bug relating to using a schema number 0.
Maybe you can try to switch to another schema number and see what happens.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Is their a good way to check if a file exists?
I have a application that creates a text file called source.txt and once an event takes place I remove it.. the problem is if something happens and for some reason the file doesn't get created it pops up an error stating that the file doesn't exist.. I was wondering what the best way would be to do a "if exists" delete it "if not" pop up a msg stating that something went wrong..
Thanks,
Rob
|
|
|
|
|
Use DeleteFile() ; it the file does not exist, the function returns FALSE and GetLastError() yields ERROR_FILE_NOT_FOUND .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Check also ERROR_PATH_NOT_FOUND and ERROR_ACCESS_DENIED
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Is this a good way of implementing what you have suggested?
DeleteFile("Source.txt");
DeleteFile("Time.txt");
DWORD dw = GetLastError();
if(GetLastError() != FALSE)
{
MessageBox("File Not Found!","Error", MB_OK);
}
It seems to work ok.
Thanks
Rob
|
|
|
|
|
Is this a good way of implementing what you have suggested?
No, it is not. DeleteFile() returns either TRUE or FALSE , and only in the latter case can you use GetLastError() to know the detailed cause of the failure:
BOOL bResult=DeleteFile("Source.txt");
if(!bResult){
DWORD dw=GetLastError();
if(dw==ERROR_FILE_NOT_FOUND){
MessageBox("File Not Found!","Error", MB_OK);
}
else{
}
}
This way of signaling errors (i.e., returning a BOOL and storing in case of failure an error code to be retrieved with GetLastError() ) is typical of many Win32 functions, so you might find it useful to get acquantied with it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you very much! I'm pretty new to programing and this kind of information helps alot!!!
Thanks again for you time,
Rob
|
|
|
|
|
http://www.codeproject.com/useritems/cwin32error.asp
that's an article bout how you can handle GetLastError Message.. i think it is a really interesting discussion in the discussion below the article.. maybe your interested..
happy learning
bernhard
stolen sig #15:
"The content of this post is not necessarily the opinion of my yadda yadda yadda."
|
|
|
|
|
Thanks!!
I will take a look at the article.. I'm very interested in learning anything new.
Thanks again,
Rob
|
|
|
|
|
I have a subroutine in a Visual C++ program using Microsoft's MCI that
records to a file named dummy.wav that already exists on C drive. If the
program is also on C drive all works well. However, if I put the program
on D drive, but still leave dummy.wav on C drive, the subroutine opens
c:\dummy.wav but will not save to it the first time the subroutine is
called. Instead it writes a temporary file of the type ~$mc331C.tmp to the
root of C. On calling the subroutine a second time, it works properly. MCI
does not report any errors when the subroutine is run. Can anyone explain
why it doesn't work the on the first call?
char strcmd[100];
wsprintf(strcmd,"open %s %s","c:\\dummy.wav","wait");
if (mciSendString(strcmd,NULL,NULL,NULL))
AfxMessageBox("error opening dummy.wav",MB_OK,NULL);
wsprintf(strcmd,"record %s %s %s","c:\\dummy.wav","from 0 overwrite to 1000","wait");
if (mciSendString(strcmd,NULL,NULL,NULL))
AfxMessageBox("error recording dummy.wav",MB_OK,NULL);
wsprintf(strcmd,"save %s %s","c:\\dummy.wav","wait");
if(mciSendString(strcmd,NULL,NULL,NULL))
AfxMessageBox("error saving dummy.wav",MB_OK,NULL);
wsprintf(strcmd,"close %s %s","c:\\dummy.wav", "wait");
if (mciSendString(strcmd,NULL,NULL,NULL))
AfxMessageBox("error closing dummy.wav",MB_OK,NULL);
Note: if I execute the program with a .pif style shortcut, the behaviour is
as described above, except that when I quit the program and then restart it,
it works properly on the first call to the subroutine, unless I reboot the
computer. However, if I execute the program with a standard Win98 or Me
shortcut, the call to the subroutine fails on the first try and succeeds on
subsequent calls every time the program is executed from the shortcut icon.
|
|
|
|
|
I would like to be able to programmatically query a process' opened files (don't confuse with EnumProcessModules). I know it is possible (TaskInfo2000 does it). Can I do that using a Win32 or Shell function/object? I wasn't able to figure out yet.
Tx
|
|
|
|
|
Hi,
I Use Visual C++ 6.0 and an access Database.
I want to execute a SQL statement with CDaoRecordset. This error message occurs : "Too few parameters. Expected 1" when i use Open method.
My SQL statement is longer than 256 characters ( about 1100 ). The problem is here it seems.
If i run This query directly in Microsoft Access, it work.
Is there any method to execute un SQL Statement like this in DAO ( CDaoDatabase ) ???
Thanks in advance
Regards,
|
|
|
|
|
Show me the line....
Cheers!!!
Carlos Antollini.
|
|
|
|
|
I use CFtpConnection to process FTP connections. But how can I check whether the connection is still opened when I get a CFtpConnection pointer? There will be many accidents to break the connection(The master closed the FTP server, net-wire broken, etc.). X|Show me some solutions, please.
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
I had the same Problem, I found a solution, doing something over the FTP Server, like a change Dir, or a FindFile, etc...
Cheers!!!
Carlos Antollini.
|
|
|
|
|
In an Mfc programm ( dialog based) i created a thread through the AfxBeginThread function .
I need that the specific class that was created will
get access to another class ( the main Dlg class)????
(i tried to use pointer but no good !)
meirav
|
|
|
|
|
You should not pass dialog pointer to the thread because it may be invalid. I think you can use GetSafeHwnd() to get the handle of the main dialog and pass it to the thread. In the thread you can use FromHandle() to get back the main dialog pointer and then you can access the main dialog class.
Here is an example:
UINT ThreadProc(LPVOID);// the thread proc
HWND hWnd; // for handle of main dialog
BOOL C???Dlg::OnInitDialog()
{
...// some codes
hWnd=GetSafeHwnd();
...// other codes
}
void C???Dlg::OnButton1() // Button1 is a sample button
{
AfxBeginThread(ThreadProc,NULL);
}
UINT ThreadProc(LPVOID lpData)
{
C???Dlg *pDlg=(C???Dlg*)C???Dlg::FromHandle(hWnd); // get the main dlg pointer
...// do what you want to do
}
You can also pass the handle through the thread proc's lpData pointer, then you don't have to declare the hWnd as a external variable.
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Thank you for your answer,
i tried what you suggest me , but there is one problem:
when i pass the LPVOID to the ThreadProc (I did it on ThreadProc::InitInstance) using the debug i saw that he never get at all to this Function .
(without the LPVOID it did get there )
it will be a great help if you can help me.
|
|
|
|
|
Could you show me your codes? I think that would be a great help.;)
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Hi,I did exacly the code you suggested in your reply above.
I can send the programm i did (it is very short ) if it is needed.
|
|
|
|
|
OK, you can either paste it or send it to my mailbox.
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Hi,
I am having a whirl of a time using MSComm, what I thought would take me 10 mins, has now taken me days not to mention my frustration level is high.. anyway here is my question, I'm hoping someone will please help me.
I am using mscomm and I need to transmit and receive binary data to my device on com 1. I am assuming that because my data consists of all unsigned characters that I can't use CString, it this correct?, I'm assuming that I must use CByteArray and then convert this to a VARIANT of which I will pass to SetOutput, How do I do this conversion?, also what is really strange is that when I am viewing my VARIANT via the debugger on my Windows 2000 machine, it appears to have the correct value within, however when I view the same on my windows ME machine it does not...
thanks for any help in advance...
|
|
|
|
|
I am looking for a "unmanaged" implementation of the .NET DataSet and its
associated objects that is written in Visual C++ (with source if possible).
I need an implementation that does not rely on the .NET FrameWork, yet is
compatible with the .NET DataSet's so I can share the XML form of the
DataSet between unmanaged clients (.NET is not installed on the clients) and
a .NET web service. We will be using the DataSet's as our universal
datapacket to pass data between the client and server.
I am trying to put off having to implement a solution myself in ATL so I am
doing some research first.
Thanks in advanced for any information or assistance.
Send Replies to jwilliams@paymetric.com
|
|
|
|