This would be;
int i = 1;
i = i + 1;
int j = i + i;
:)
This would be;
int i = 1;
i = i + 1;
int j = i + i;
:)
VirtualAlloc
never allocate over 2GB in 32bit windows without /3GB option. In some ordinary OS settings situation, VirtualAlloc
usually returns under 1.5GB space for user land memory. And AWE
is for use of physical memory over physical 2GB boundary with /pae boot option. If you want continuous virtual memory space over 2GB, you must use 64bit windows. With /pae boot option, msdn document says VirtualAlloc
can use over 4GB physical memory, but it would not so ordinary 32bit windows especially xp. Because microsoft dose not support over 4GB physical memory on 32bit xp.
Assign unique value for duplicated id, simply. You should assign all unique (different) id for different controls. Only one handler will be called for one id value on MFC message mapping. Because MFC's message mapping is very simple implement which using array of struct, and decide handler by sequential searching. When message map is as below;
BEGIN_MESSAGE_MAP(CSampleDlg, CDialog)
//{{AFX_MSG_MAP(CSampleDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Compiler recognize as below; (rewriting simply)
struct MessageEntry messageEntries[] = {
{ IDC_BUTTON1, OnButton1 },
{ IDC_BUTTON2, OnButton2 }
};
If IDC_BUTTON1 and IDC_BUTTON2 are equal, the sequential searching algorithm always find OnButton1 for IDC_BUTTON{1,2}.
I dont understand your problem point yet. Will you explain the point for short again? :confused:
Default implementation of new
of vc is malloc
and malloc
calls VirtualAlloc
. I checked how much memory's can be allocated on my pc with XP SP3. Available Phys. Memory: 1.7GB (from task manager) Available Virtual Memory: 2.0GB (from GlobalMemoryStatusEx
) My program allocated: 1.5GB (by VirtualAlloc
or malloc
) My program's Total Virtual Size: 1.5GB (from task manager) In general, total virtual memory space 2GB is sum of program own code size, some resources and other crt dll space size. So in this case, my program's size without heap should be around 500MB. (I think this strange.) I guess some other programs (like a anti virus program or so) or some Windows settings affected to this situation.
Which API did you call to allocate memory?
A sample;
int array[3][4][5] = {
{ //[0][][]
{ 1, 2, 3, 4, 5 },//[0][1][]
{ 1, 2, 3, 4, 5 },//[0][2][]
{ 1, 2, 3, 4, 5 },//[0][3][]
{ 1, 2, 3, 4, 5 } //[0][4][]
},
{ //[1][][]
{ 1, 2, 3, 4, 5 },//[1][1][]
{ 1, 2, 3, 4, 5 },//[1][2][]
{ 1, 2, 3, 4, 5 },//[1][3][]
{ 1, 2, 3, 4, 5 } //[1][4][]
},
{ //[2][][]
{ 1, 2, 3, 4, 5 },//[2][1][]
{ 1, 2, 3, 4, 5 },//[2][2][]
{ 1, 2, 3, 4, 5 },//[2][3][]
{ 1, 2, 3, 4, 5 } //[2][4][]
}
};
This is just the solution for original question, I think. :)
What compiler do you use in your IDE environment? I think __declspec(dllexport)
is only for MS compiler, not for gcc.
You can make the manager service which spawn multiple instance of some program. If you mean multiple processes by multiple, the manger service is like below;
// define some structure for managing status.
struct MyProcInfo {
BOOL m_spawnSucceeded;
PROCESS_INFORMATION m_processInfo;
} m_myProcInfo[N];
...
// execute and hold handles
for (int j = 0; j < N; j++) {
m_myProcInfo[j].m_spawnSucceeded = CreateProcess(SOME_PROGRAM, argsForIt, ...., &m_myProcInfo[j].m_processInfo);
}
Or if you do not mean multiple processes but multiple COM instances, you can easily write like that service with ATL COM AppWizard wizard in visual studio.
Why do you want to know that? What for?
One solution is using Multiple Precision Number library like http://gmplib.org/[^]
Thanks your pointing out. That was a Java style coding. In c++, ordinarily;
throw TException("func1");
catch(TException& e) {
}
And I know void main
is not compatible in c++. That was only concept codes, but may not be so good example.
Why don't you use c++ exception semantics? It might be as below.
struct TException;
void func1()
{
cout<<"abc";
throw new TException("func1");
}
void func2()
{
cout<<"def";
}
void main()
{
try {
func1();
}
catch (TException* e) {
e->printSomthing();
delete e;
}
catch(...) {
cerr<<"general exception which I dont know"<
One question.
DWORD dwPIDLst[1024];
nPIDNum = dwBytesWritten / sizeof( DWORD );
Was it ok? In other words, nPIDNum is under 1024?
You must watch every time its file changing if you want know. I don't know the general watching process for the reason. So, you can write some code which reads the file and sense difference of it by yourself.
> why it is happened . Os is very different. It is just a reason. Generally, many program which can run on xp will not be able to run on vista because of incompatibility between xp and vista. The most incompatibility of os is around security. Check the API's document you used, and you might find some clue of them; incompatibilities.
I can say one of old style of coding (not a .net style, I'm saying) with WinInet. The primary usage is thus; <pre> HINTERNET hInet = InternetOpen("MyLocalAgent", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); HINTERNET hFile = InternetOpenUrl(hInet, "http://king.ath.cx/server.txt", NULL, 0, 0); BYTE buffer[BUFSIZE]; DWORD dwRead; while (InternetReadFile(hFile, buffer, BUFSIZE, &dwRead)) { if (0 == dwRead) break; fwrite(buffer, 1, dwRead, stdout); } InternetCloseHandle(hFile); InternetCloseHandle(hInet); </pre>
Check the calling convention of those exported functions. The default calling convention is __cdecl
but some API function requires __stdcall
.
Try WritePrivateProfileString(NULL, NULL, NULL, L"inifile.ini")