|
Hi,
I have recently been working on my first big C++ application, and it has quite a lot of persistent Registry entries.
Anyway, when I want to know an app setting, I am doing AfxGetApp()->GetProfileXXX... to get the setting.
My question is this: is it slower to keep calling that function or to hive off the settings and keep updating that hive if the settings are changed?
Example #1:
A loop 10,000 times with a Registry call each loop is probably slower than reading the value out and then looping 10,000 times.
Example #2:
An event fires (such as WM_CHAR) that reads a setting and uses it once before the end of the handler. Is this slower than having the external hive?
Input, ideas and peep's programming practices in this field greatly appreciated.
Thanks in advance,
Si
|
|
|
|
|
I recommend that you read the config settings at program startup and store them somewhere instead of re-querying the registry every time you need a value.
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
This is what I thought.
I was just wondering whether AfxGetApp() within MFC did some smart cacheing of values.
I would have thought not, but here's hoping.
|
|
|
|
|
It's not AfxGetApp() that's slow (trace into it and see), but doing thousands of registry calls is. The registry is a database, and access won't be lightning-quick. As Nish said, read your config into variables at startup, then save it on exit.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Is it possible to copy a parent image and have its children appear in different locations to the parent?
I'm trying to create a side on scrolling shoot-em up and I want to be able to fire five (5) bullets at one time but I don't want to have to write the code 5 times...
GetBulletStartPoint[1];
SetBulletVisible[1];
If(Bullet = OffScreen) AllowNewBullet[1];
etc etc...
Hope this makes sense I can compile what I'e made so far and post on my site if that will help...
|
|
|
|
|
No - you will need to draw them all yourself, you can't make a single image redraw itself automagically.
You should be writing it five times though, you should use an array ( maybe as a list ) of Bullet objects and a loop.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Hey all.
I want to be able to display tooltips text in a different codepage from the system's current default codepage (in a non-Unicode OS, such as Windows 98, Windows ME, etc.)
Any ideas?
Thanks!
|
|
|
|
|
Hey, Im having some trouble with capturing some events in Outlook. I was wondering if anyone had, or could give me an example of how to overide an event such as the "open" event.
Right now I have this...
I derive my class from IDispSimpleEventImpl...
class ATL_NO_VTABLE CDaFun :
public IDispEventSimpleImpl<1,CDaFun,&__uuidof(Outlook::ItemEvents)>
typedef IDispEventSimpleImpl<1, CDaFun, &__uuidof(Outlook::ItemEvents)> ItmEvents;
Then setup a callback...
void __stdcall OnOpenItem(IDispatch* Ctrl, VARIANT_BOOL * CancelDefault);
and then the sinkmap...
SINK_ENTRY_EX(1,__uuidof(Outlook::ItemEvents),0xf003,OnOpenItem)
Now Advising im not sure about. Try to get a pointer to the interface i need. Im not sure if Inspectors is right...
CComQIPtr <outlook::_application> spApp(Application);
CComQIPtr <outlook::_inspectors> spInsp;
spInsp = spApp->Inspectors;
ItmEvents::DispEventAdvise((IDispatch*)spInsp,&__uuido(Outlook::ItemEvents));
The advise fails, so im not how to set that up right. Please help
THanks
TENK
|
|
|
|
|
I have an ISAPI extension that runs another app when it is finished. This other app needs to have write access to a directory.
How can I run this process as another user?
I have tried CreateProcessWithLogonW but got a link error. I assumed it was because I was not building in unicode. Unfortunately, I don't have a unicode build configuration so forget that.
Is there a way to tell IIS to run a dll as a certain user?
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
There is the CreateProcessAsUser() API. I haven't used it a lot though - you need to get a security token for the user and pass it in.
Although I might soon try to do just this - have an EXE or a DLL that launches another EXE as a different user. I suppose if you could get that to work directly, you could always have IIS launch a DLL which launches an EXE to run as a different user.
As for launching a DLL as another user - is that possible? Since a DLL will technically run in the memory space of the executable that calls it, so they are essentially one program - but I'm somewhat ignorant in this regard.
Even if you win the rat race, you're still a rat.
|
|
|
|
|
You have to call LogonUser before calling CreateProcAsUser. Not sure I want it to load the profile etc.
Thanks for the reply.
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
How do you do this?? Ala internet explorer - where when too many windows minimize they begin to stack in a group...
when my dialog boxes minimize now they go on top of the taskbar, not in the taskbar... how do i make this transistion?
-kevin
|
|
|
|
|
Anonymous wrote:
How do you do this?? Ala internet explorer - where when too many windows minimize they begin to stack in a group...
That's XP feature where windows with the same title text get stacked [I think only the first few characters are compared though]
Anonymous wrote:
when my dialog boxes minimize now they go on top of the taskbar, not in the taskbar... how do i make this transistion?
You mean, they minimize to an icon on the desktop, instead of to the taskbar?
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
Here are the style adjustments I make to a modeless dialog.
pTemplateEx ->style |= WS_MINIMIZEBOX | WS_SYSMENU;
pTemplateEx ->exStyle |= WS_EX_APPWINDOW;
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
U mean register or registry, cos there's a difference u know!
Papa
Murex Co.
|
|
|
|
|
For registry access u can call from ur CWinApp object if ure using MFC,
GetProfileInt
WriteProfileInt
GetProfileString
WriteProfileString
By the way, what are u using??
Papa
Murex Co.
|
|
|
|
|
|
Hello! I'm trying, by code, to insert the '\n' or 0x0D or chr(13) into a EditBox to format the data comingo from a Database.
Anyone have a clue on how to do this?
Thank you for your time!
|
|
|
|
|
Try \n\r that should do it!
Papa
Murex Co.
|
|
|
|
|
there are a few ways. the easiest is to add the "\r\n" to the data then do a SetWindowText to add all the data at once. (you need the '\r', or the edit box will draw a little square for the '\n').
CString inData;
inData = from database
inData+="\r\n";
myEdit.SetWindowText(inData);
-c
Cheap oil. It's worth it!
|
|
|
|
|
sData = ...
sData += "\n";
m_cEdit.SetWindowText(sData);
|
|
|
|
|
Chris was rigth, i must insert "\r\n", to make the line feed. Thank you all!
|
|
|
|
|
Hi,
I have window A (which might be a dialog or a SDI) and window B which is a dialog. Window A creates window B modally.
I wanna have a button on window B which closes both window B and window A regardless of whether it is dialog or SDI but I dunno how.
Thanks for your help.
R.
|
|
|
|
|
U can do it several ways, but guess the simplest object oriented way would be to pass a pointer of the dialog A to the dialog B, and all the button would have to do is to call:
OnOK();
m_pointerToDialogA->OnOK();
Papa
Murex Co.
|
|
|
|
|