|
a variable can be declared auto matic, such as static or register .
auto matic is the implicit type when you declare a variable without specifying this statement.
for information, register will ask the compiler (but not force it to) place the variable into a processor register. this is for a variable that is often modified, to improve performances.
static has several meaning. here, we do not talk about the static on class members.
delcaring a variable static means that its value pertains wether the execution goes out of scope. out of the scope, the variable is not destroyed (thus keeping its last value for the next time the code is reexecuted), but not much accessible from outside.
auto matic simply means what we all know about variables lifetime. A variable is created at its declaration, is is release straight when going out of scope.
register double = 4.;
static char c = 'B';
auto int i1 = 3;
int i2 = -7;
|
|
|
|
|
Cool! I think your post is the most valuable which deserves rate 5.
have a good weekend,
George
|
|
|
|
|
|
It appears so, but he is still keeping his age a secret.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
What are the odds he's not as old as you or as ugly as me?
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks DavidCrow,
Good learning resource.
regards,
George
|
|
|
|
|
Hi,
days ago I post a question that has not been answered.
This is the question[^]
If you don't mind... I would like to have an answer, although it says "message too long, bad explained, there is no solution... ", of course I would prefer a tip, or something that help me to resolve it.
-- modified at 4:59 Friday 9th November, 2007
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hi All,
What enum in VC++ 6.0 is equivalent to LinearGradientMode (VC++.Net)?
|
|
|
|
|
Do you need to GRADIENT_FILL_RECT_V or GRADIENT_FILL_RECT_H for set gradient mode?
|
|
|
|
|
The GDI+ Brush can do linear gradients.
|
|
|
|
|
Since VC++.Net (GDI+) has LinearGradientBrush and LinearGradientMode, i want equivalent methods in VC++ 6.0.
|
|
|
|
|
You can use GDI+ with Visual C++ 6.0
|
|
|
|
|
VC++ documentation tells, GetPrivateProfileSection is provided only for compatibility with 16-bit applications.
Can we use this function in VC++ .Net 2003?
Best Regards,
Suman
|
|
|
|
|
In the continue MSDN says that:"Applications should store initialization information in the registry."
|
|
|
|
|
rp_suman wrote: Can we use this function in VC++ .Net 2003?
Yes.
But you can alternatively use, as recommended, the 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.
|
|
|
|
|
Hi
I want to know, if some user is logged on the machine, this from a Win32 Service runing under LocalSystem Account...
Thk.
|
|
|
|
|
From MSDN:
Use WTSEnumerateSessions function to retrieve a list of sessions on a specified terminal server.
Or use WTSGetActiveConsoleSessionId function to retrieve the Terminal Services session currently attached to the physical console. The physical console is the monitor, keyboard, and mouse. Note that it is not necessary that Terminal Services be running for this function to succeed. Then use
WTSQueryUserToken function to obtain the primary access token of the logged-on user specified by the session ID. To call this function successfully, the calling application must be running within the context of the LocalSystem account and have the SE_TCB_NAME privilege. It is not necessary that Terminal Services be running for the function to succeed, but if Terminal Services is not running, the only valid session identifier is zero (0). Windows Vista and Windows Server "Longhorn" allow only services and processes started by services to run in session zero.
Caution WTSQueryUserToken is intended for highly trusted services. Service providers must use caution that they do not leak user tokens when calling this function. Service providers must close token handles after they have finished with them.
|
|
|
|
|
it was just what I need... thk
SOAD
|
|
|
|
|
You might also want to see about RegisterServiceCtrlHandlerEx. The HandlerEx function is an application-defined callback function used with the RegisterServiceCtrlHandlerEx function. A service program can use it as the control handler function of a particular service. The control handler function is intended to receive notification and return within 2-3 seconds; it should start another thread to perform additional work.
It can receive notifications when a user has logged on and off: SERVICE_CONTROL_SESSIONCHANGE
If dwControl is SERVICE_CONTROL_SESSIONCHANGE, dwEventType can be one of the values specified in the wParam parameter of the WM_WTSSESSION_CHANGE message. All sorts of these parameters indicate if there was a log on or log off or other change to the session.
If dwEventType is SERVICE_CONTROL_SESSIONCHANGE, lpEventData is a WTSSESSION_NOTIFICATION structure.
Use this to determine which session to check.
|
|
|
|
|
Hi all,
Using my application I've found a file path anywhere on my machine and store the full path in a CString variable. That full path, like this,
"F:\\Files\\Read_File.txt"
What I want to do is, find the name of the file(without the extension), and then separate two words Read and File.
I have tried one thing. Use ReverseFind() method of CString class to find the last '\' sign. Then I used the Right() to get the required file name. I can use Right() easily because file name length is always fixed.
<br />
CString ss = "F:\\Files\\ReadFile.txt";<br />
CString aa;<br />
<br />
if(ss.ReverseFind('\\')== 8)<br />
{<br />
AfxMessageBox(ss.Right(12), MB_OK);<br />
aa = ss.Right(12);<br />
}<br />
<br />
if(aa.ReverseFind('.')==8)<br />
{<br />
AfxMessageBox(aa.Left(8), MB_OK);<br />
}<br />
In this way I can separate those two words as well.
Actually this code gives the file name, ReadFile.
But there is a real issue, on the first 'if' condition. First part of the path, that is "F:\\Files" is not fixed. So in the first 'if' condition number 8 can be change depend on the file selection on my PC. How can avoid that.
Thanks
I appreciate your help all the time...
Eranga
|
|
|
|
|
ReverseFind gives you the location in the string of the certain character you are searching for. Using that it can already be flexible regardless of the length of the filename. To get the application name you can use:
aa = ss.Right(ss.GetLength() - (ss.ReverseFind('\\') + 1)); //add 1 to exclude the '\'
with some adjustments, almost the same procedure can be done to get the file name (without the extension)
aa.Left(aa.ReverseFind('.'));
For flexibility you can try to pass the result of ReverseFind to an int first to check if it returns -1 (character not found).
|
|
|
|
|
Ok, I've do it in this way.
<br />
CString ss = "F:\\SRF Resources\\SRF\\G00166_003_01.srf";<br />
<br />
CString aa, bb;<br />
<br />
aa = ss.Right(ss.GetLength() - (ss.ReverseFind('\\') + 1));
AfxMessageBox(aa, MB_OK);<br />
<br />
if(aa.ReverseFind('.') == 13)<br />
{<br />
bb = aa.Left(13);<br />
AfxMessageBox(bb, MB_OK);<br />
}<br />
What is your comments.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: if(aa.ReverseFind('.') == 13)
{
bb = aa.Left(13);
AfxMessageBox(bb, MB_OK);
}
Even if you have a fixed filename length wouldn't it be better to just use:
<br />
if(aa.ReverseFind('.') != -1)<br />
{<br />
bb = aa.Left(aa.ReverseFind('.'));<br />
AfxMessageBox(bb);<br />
}
It is much more flexible if the filename was changed to another one.
Also, you can just use AfxMessageBox(bb); instead of AfxMessageBox(bb, MB_OK); since the default for AfxMessageBox is the one with OK button anyway.
|
|
|
|
|
Llasus wrote: Even if you have a fixed filename length wouldn't it be better to just use:
Yep, it's better. At the same time I've try another way to do this, but felt so mess. Use Find() to get the last '\' and then read backward to find the name. Try to follow the same way to find '.' and avoid extension. Failed. :->
Llasus wrote: Also, you can just use AfxMessageBox(bb); instead of AfxMessageBox(bb, MB_OK); since the default for AfxMessageBox is the one with OK button anyway.
Thanks pal for the infor. I just used it, because I feel it is completed my code in view. Actually it is useless. I have to type more and more when I used message box. Actually on my testings I used more message boxes to verify my output.
I appreciate your help all the time...
Eranga
|
|
|
|