|
1、BOOL is Microsoft's macro . In fact, is only 4 bytes of int type. This definitions ,you can find it in the VC setup directory (WINDEF.h、AFX.H), It can be found this following code:
typedef unsigned long DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef float FLOAT;
#define FALSE 0
#define TRUE 1
#define NULL 0
bool is C/C + + keywords, about MSDN2005 help document, explained below:
This keyword is a built-in type. A variable of this type can have values true and false. Conditional expressions have the type bool and so have values of type bool. For example, i!=0 now has true or false depending on the value of i.
The values true and false have the following relationship:
When a postfix or prefix ++ operator is applied to a variable of type bool, the variable is set to true. The postfix or prefix -- operator cannot be applied to a variable of this type.
The bool type participates in integral promotions. An r-value of type bool can be converted to an r-value of type int, with false becoming zero and true becoming one. As a distinct type, bool participates in overload resolution.
2、Define BOOL and bool of the reasons.
In the memory space,the true、false、null is occupying 1 bytes.But TRUE、FALSE、NULL is occupying 4 bytes.
According to the Intel CPU's paging memory mechanism, 4 bytes can prevent memory inattentive,
it can prevent to produce more ram pieces,and help the data transmission. 
|
|
|
|
|
Hi Guru,
Please correct me. I am trying to delcare, define, and call a two dimensional array like:
declare in the header file:
void CCvib_procDlg::time(float*);
Define:
void CCvib_procDlg::time(float delms[][6])
{ ... code ... }
call:
time(&delms[0][0]);
When I tried to compile, I got:
error C2511: 'time' : overloaded member function 'void (float [][6])' not found in 'CC_vib_procDlg'
Please correct mm. Thanks
modified on Wednesday, May 5, 2010 4:39 PM
|
|
|
|
|
The signature for the declaration and definition must be the same.
Use void time(float delms[][6]); in the header file.
|
|
|
|
|
Thanks,I changed the code to what you suggest:
declare:
void class:time(float delms[][6]);
define:
void class:time(float delms[][6]) { ...};
but the call:
time(delms)
not compile, giving error:
error C2664: 'time' : cannot convert parameter 1 from 'float ** ' to 'float [][6]'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Please correct
Thanks
|
|
|
|
|
|
Thanks.
This is how delms declared:
float**delms;
delms = new float*[1000];
for (int i=0;i<1000;i++)
{
delms[i]=new float[6];
for (int j = 0; j < 6; j++)
delms[i][j] = 0.0;
}
|
|
|
|
|
In this case make the declaration and definitions as -
void time(float* delms[6]);
|
|
|
|
|
Thanks. It compiles.
Since the square brackets have a higher precedence than the de-referencing operator, this declares an array of 6 pointers to the type float
Any comments please?
Thanks
modified on Wednesday, May 5, 2010 7:12 PM
|
|
|
|
|
I would suggest you spend some time practicing reading declarations using the right-left rule[^]. It's invaluable to really understand what's going on.
The wonderful thing about the Darwin Awards is that everyone wins, especially the members of the audience.
|
|
|
|
|
It compiles. I run the function and it give me error:
DAMAGE: after normal block (#125) at 0x00E40610
Thank you.
|
|
|
|
|
times(float (*delms)[6]) will work.
|
|
|
|
|
Thanks,I changed the code to what you suggest:
declare:
void class:time(float (*delms)[6]);
define:
void class:time(float *delms)[6]) { ...};
but the call:
time(delms)
not compile, giving error:
error C2664: 'time' : cannot convert parameter 1 from 'float ** ' to 'float (*)[6]'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\msw_give_out\msw_shotplus_i_format\class.cpp(2144) : error C2511: 'time' : overloaded member function 'void (float (*)[6])
' not found in 'class'
c:\msw_give_out\msw_shotplus_i_format\class.h(16) : see declaration of 'class'
feature_display.cpp
Error executing cl.exe.
blast_vib_multi_seed_model.exe - 2 error(s), 0 warning(s)
|
|
|
|
|
my fault not having seen your code before.
|
|
|
|
|
|
As has already been suggested, please spend some time (here, for example) knowing the differences/similarities between arrays and pointers when using functions. Without that knowledge, you are going to continue to face the same struggles.
That said, have you tried:
void CCvib_procDlg::time(float**, int dim1, int dim2);
...
time(delms, 1000, 6);
I would refrain from naming a function time() as it could be confused with the time() function.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi Guys, It works!
Here are codes to share with you and thanks. In particular, DavidCrow and _Superman_:
float **tim_var;
tim_var = new float*[1000]; <<----------
|
for (int x = 0; x < 1000; x++) |
{ |
tim_var[x] = new float[6]; <<----- |
| |
for (int y = 0; y < 6; y++) | |
tim_var[x][y] = 0.0; | |
} | |
| |
for (x = 0; x < 1000; x++) | |
delete [] tim_var[x]; <<---------- |
|
delete [] tim_var; <<-------------------
Above From: DavidCrow
How to pass 2D array in a function
Declare:
void Cvib_procDlg::delay_time(float *delms[6]);
Define:
void Cvib_procDlg::delay_time(float *delms[6])
{
....}
Call:
delay_time(delms);
From:
«_Superman_» I love work. It gives me something to do between weekends.
|
|
|
|
|
Dear Sirs,
I am beginner in C++ and have problem with one my program.
I am C++ dll for protection my Expert advisor(Metatrader software).
I want make demo version for my client and want using time limit on that.
For example each client able use this software for 7 days and after that not workable for him/her.
I want simple code that check this time for me.
I am using win32 console.
Thanks.
|
|
|
|
|
1- Don't waste time on that. If your program is worthy enough, then it WILL be cracked/hacked whatever you do and you will loose a lot of valuable time working on "security" instead on the core business of your application.
2- Release a version of your software with a limited set of function and features with code REMOVED from the executable. (for example no save/export/report, limit the number of trade per day/hours, ...)
...
Watched code never compiles.
|
|
|
|
|
dear sirs,
thank you for your email.
I want use this timer in dll no in original source.
You know cracking dll is hard.
Thanks.
|
|
|
|
|
I second Maximilien suggestion. Anyway, you may write usage info, crypted, inside the Windows registry.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can anybody tell how I get the window handle from a specific process Id. I got the process Id using GetCurrentProcessId()
Regards
Rajmohan
|
|
|
|
|
Which window handle? There are usually more windows belonging to a process (e.g. controls on a dialog like buttons, edit fields have a window handle too). Anyways, i assume you are looking for a top level popup window, one method would be to enumerate all the windows, for example using EnumWindows[^], on every window you could call GetWindowThreadProcessId[^] to get the id of the process the window belongs to and test for equality...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
The handle of what window?
To retrieve all windows of a process, you have to call EnumWindows and, for each window, use GetWindowThreadProcessId to check if a window belongs to a process (the ProcessID of the window equals the ProcessID of the process).
|
|
|
|
|
EnumWindows function is working fine with all windows except my application. I will describe the issue in detail. I have a dll application and I have loaded it into App_Init folder, which loads for every application. I want to know which is currently loaded application and also I need to get the handle of the main window.
I used EnumWindows for navigating through opened application. It is calling for all the application except mine. I dont understand the issue can anybody help me.
Thanks in advance
Regards
Rajmohan
|
|
|
|
|
GetWindowThreadProcessId
what about this?
|
|
|
|