|
Try:
CMyClass** myClass = new CMyClass[];
myClass[i] = new CMyClass();
John
|
|
|
|
|
Hi John.
Now throws:
error C2440: 'initializing' : cannot convert from 'class CMyClass *' to 'class CMyClass ** '<br />
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
I don't know what happend.
|
|
|
|
|
Sorry my fault:
CMyClass** myClass = new CMyClass*[NUMBER_TO_ALLOCATE];
myClass[i] = new CMyClass();
John
|
|
|
|
|
you don't need the second line...
all the cells of the tab will be automatically created with the default constructor...
your myClass[i] = new CMyClass(); is so redondant..
regards
TOXCCT >>> GEII power
|
|
|
|
|
No the first line creates an array of pointers to CMyClass and the second line Creates the object instance.
John
|
|
|
|
|
CMyClass* myClass = new CMyClass[]; don't mean nothing... how many bytes will be allocated ??
prefer that :
<font style="color:blue;">#define</font> TAB_SAZE 10 <font style="color:green;">// for example
</font>
<font style="color:blue;">int</font> i=0;
CMyClass* myClass = new CMyClass[TAB_SIZE];
<font style="color:green;"></font> <font style="color:green;">
<font style="color:green;">
</font>
I assume that you have the needed operators written, or that you will...
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
/* myClass[i] = new CMyClass(); */ // not needed anymore. // each object is now initialized as the default constructor would do...
This was this line that throw the error (and so when you say this is not needed anymore, you'll have to say this CAN'T BE USED !).
In fact when you write:
CMyClass* myClass = new CMyClass[TAB_SIZE];
you are declaring an array of OBJECTS and not an array of pointers to object. So myClass[i] is an object and not a pointer !!
So this is totally wrong to write such a thing: myClass[i] = new CMyClass(); .
Hope this helps
|
|
|
|
|
Hi, i´d like to put and retreive to-from a LPBYTE variable data from a class, like
class A
{
int a;
double b;
LPBYTE GetStream();
} void SetStream(LPBYTE lpData, DWORD dwLen);
...
A class1,class2;
LPBYTE stream = class1.GetStream();
class2.SetStream(stream)
Qhris!
|
|
|
|
|
How does one go about opening a file that is located in the directory of the executable without using any code that is OS-dependent (not microsoft functions)?
(The user could be in a directory different from where the executable is located, and run that executable, which opens a file in the directory where the executable is located.)
Thanks!
|
|
|
|
|
In standard C, I am prertty sure that the argv[0] command line argument to main usually has the full path of the executable file. Strip off the program's file name, you are left with the path to folder where exe is located.
|
|
|
|
|
Okay, "HOW TO: Write an Applciation That Supports Fast User Switching in Windows XP".
Yep, another technically accurate but totally worthless document from Microsoft
Statements like "Block any problematic features' are useless. Well, what could I expect to be problematic? If I blocked the user from switching, the app would work fine.
So, now that I have the session switch notifications in the program and I get WTS_SESSION_LOCK and WTS_SESSION_UNLOCK, what kinds of activity should I PREVENT while the session is locked?
My program is actually returning ACCESS DENIED (GetLastError = 5) on a call to the Rectangle(HDC, int, int, int, int) GDI function!
And of course, they have the classic 'FindWindow' example of locating an existing instance..
Any worthwhile ideas?
|
|
|
|
|
Will UrlDownLoadToFile() works fine when used from a NT Service application running under System account.
As far as i know this function uses IE settings to download URLs. So i am afraid whether Local System account will be able to access IE settings ?
|
|
|
|
|
i am trying to update a record for which i create a new query example:
CDatabase DB;<br />
<br />
<br />
CString sAddress;<br />
sAddress = _T("11 pivot drive st'micheals");<br />
<br />
<br />
CString sSQL<br />
sSQL.Format(_T("Update TableNameHere Set Address='%s'),sAddress);<br />
<br />
DB.Execute(sSQL);
since the string sAddress contains a ' character in it the query wont execute.
do i have to replace ' with \' or is there any other way outta this
thanks
|
|
|
|
|
Modify your routine to escape the ', which consists of doubling them.
Ex:
11 pivot drive st'micheals
becomes
11 pivot drive st''micheals
NOTE: Don't use the " character !
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
I want use Timer in my Service prog,and add this code:
SetTimer(NULL, 0, 1000, Timer2);
Timer2 is a function name in my deifned Class.but when the prog compile,it shows that :error C2664: 'SetTimer' : cannot convert parameter 4 from 'void (struct HWND__ *,unsigned int,unsigned int,unsigned long)' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)'
who can tell me:what is my problem?
class CServiceWnd : public CWinThread
{
void CALLBACK Timer2(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime);
int m_Timer2;
..................
}
void CALLBACK CServiceWnd::Timer2(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{
if(Createsocket())
{
KillTimer(NULL,m_Timer2);
}
}
void CServiceWnd::OnClose()
{
...................
m_Timer2=SetTimer(NULL,0, INTERVAl,Timer2);
}
|
|
|
|
|
Your timer callback function should either be a static member function or a global function. If you want to use a nonstatic member function as a calback then you have to jump through a few hoops. See http://www.codeproject.com/cpp/SoloGenericCallBack.asp[^] for details.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Timer32() should not be a member of the CServiceWnd class. That's why it does not match the required prototype. The this pointer is getting in the way.
One solution would be to pass NULL as the third parameter to SetTimer() , and then provide an OnTimer() function of your CServiceWnd class. From there, you can call CreateSocket() , etc.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I got a program running in multiple processes on the same machine and all of them are writing to the same log file.
I want to make sure that they are not trying to write to the log at the same time.
And need some sort of locking or criticalsection type of thing that works over different processes.
Any one got any tips?
|
|
|
|
|
|
You probably want it to be a named mutex unless your log code is in a common dll and you have declared the mutex in a shared section.
John
|
|
|
|
|
If you are also guarding against multiple USER sessions, you need to be aware of terminal services issues, and also to apply more than 'NONE', EMPTY', or 'NULL DACL' security on the synchronization object or no one else will be able to open it up right all the time.
I am pulling my few remaining hairs out sorting this all out for terminal services and Windows XP Fast User Switching.
|
|
|
|
|
Aside from the mutex, you can open your log file exclusively. I believe the CFile::Open function returns a bool if the file opens, so if your file doesn't open, it means somebody else (another app) is using that file, so just let your app keep trying until it gets access. I wouldn't go trying this on a file where more than a few applications (threads) are going to be using it, but it's a cheap little way of assuring you have exclusive access to your file. However, the code can get a little tricky because you also need to make sure that the file actually exists before you enter a loop that tries to open it exclusively...otherwise your program will go into an infinite loop. The only real benefit of using this method is that you can share your log file on a network, and have your application on multiple computers share it...don't know if you're getting that complex or not (if you are, look into using a database instead.) Good luck
|
|
|
|
|
I'm writing a C++ DLL and am trying to incorporate a call to the FlashWindowEx API. Yet when I compile it errors out that it does not know this API call (error C2065: 'FlashWindowEx' : undeclared identifier). I added the winuser.h file to my code and the user32.lib to my project properties. Still is does not find it.
Has anyone got any suggestions?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
|
Michael
Not sure this pertains to me. As I'm writting this on a laptop that has VS 6.0 and .NET studio with MSDN for .NET 2003 installed on it. Also this app is only intended to run on XP or 2000.
Here is a break down of my app header file:
#ifdef WINSTYLE_EXPORTS<br />
#define WINSTYLE_API __declspec(dllexport)<br />
#else<br />
#define WINSTYLE_API __declspec(dllimport)<br />
#endif<br />
<br />
<br />
<br />
extern WINSTYLE_API char nWinStyle; <br />
WINSTYLE_API int GetCloseWin(char);<br />
WINSTYLE_API int GetOpenWin(char);<br />
WINSTYLE_API int GetCloseApp(char);<br />
WINSTYLE_API int SetWinFocus(char);<br />
WINSTYLE_API int SetWinFocusEx(char);<br />
and my stdafx.h file
<br />
#if !defined(AFX_STDAFX_H__4D8BF925_F169_11D4_8093_0050DA27906F__INCLUDED_)<br />
#define AFX_STDAFX_H__4D8BF925_F169_11D4_8093_0050DA27906F__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
<br />
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers<br />
<br />
#include <windows.h><br />
<br />
<br />
<br />
#endif // !defined(AFX_STDAFX_H__4D8BF925_F169_11D4_8093_0050DA27906F__INCLUDED_)<br />
Do I still need to add the defines even though it will never run on anyhting below W2k?
Thanks for the help.
Tom Wright
tawright915@yahoo.com
|
|
|
|