|
I am currently writing an installer (using the Windows Installer Setup Project from VC .net) and need to install along with the package a couple of Command Line tools. I would like to update the windows PATH environment variable at install / uninstall time.
Does anyone know the "Correct" way of doing this, rather than just hacking about with the registry.
Thanks
Dave
|
|
|
|
|
Try this:
TCHAR tszBuf[MAX_PATH];
GetEnvironmentVariable("PATH", tszBuf, MAX_PATH);
Maybe not the best way, but at least better than reading it directly from the registry
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Hi
I have a threaded app which can have many threads running (number not known until runtime). Each thread needs to use shared resource so I lock with WaitOnSingleObject and pass a handle to a mutex. The handle is a global variable assigned with CreateMutex so all threads have access to it and this method works fine.
Whilst one thread has access to the shared resource, other threads are sitting INFINITE at the WaitOnSingleObject. Do these threads get access on a first come first served basis or is there a possibility that a thread could constantly be shoved to the back of the queue by others threads pushing in?
Which leads me onto a second question - can you give a thread higher priority (easily) ?
Cheers
Angel1058
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
The queue to get access to the mutex is on a first-in, first-out basis. So the first thread to wait on the mutex will get access to it when it is released, regardless of thread priority.
Mike
|
|
|
|
|
The scheduler makes no promises, except that it will be "fair to all threads" (which is enough for your case).
Also, there are substantial differences in the scheduler implementation between 9x and NT platforms.
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
can't find sources for ShellIconChanger.zip FILE
|
|
|
|
|
|
I am writing a simple NFO file viewer and I need additional information on how to create the file association. Does anyone know any good tutorials on this. Additionally, since the NFO file type is set for the MSInfo application by default in Win it may have special considerations. Any information about additional concerns I should have would also be useful.
|
|
|
|
|
You did not specify whether you were using MFC or not. If you are, check out CWinApp::EnableShellOpen() and CWinApp::RegisterShellFileTypes() .
If you are not, here is a .reg file from an app that I wrote called RegWatch. You would simply need to replace "regwatch" (and variations of) with the name of your app and "rw" with the extension you want to register.
REGEDIT
; This .REG file may be used by your SETUP program.
; If a SETUP program is not available, the entries below will be
; registered in your InitInstance automatically with a call to
; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll.
HKEY_CLASSES_ROOT\.rw = RegWatch.Document
HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\command = REGWATCH.EXE %1
HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\ddeexec = [open("%1")]
HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\ddeexec\application = REGWATCH
; note: the application is optional
; (it defaults to the app name in "command")
HKEY_CLASSES_ROOT\RegWatch.Document = RegWat Document
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Sorry, I am not using MFC. My intention is to make the app as small as possible and a single file. I suppose I would be able to output this to a temp file then run some command to merge it into the registry. Do you know how I would go about merging it into the registry without the messagebox that says "Are you sure you want to add this to the registry?" appearing?
|
|
|
|
|
KRowe wrote:
I suppose I would be able to output this to a temp file...
Yes, as long as it has a .reg extension.
KRowe wrote:
Do you know how I would go about merging it into the registry without the messagebox that says "Are you sure you want to add this to the registry?" appearing?
What's wrong with that message? In any case, you could update the registry via code using the registry API, or the CRegKey class?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Now that I think about it...I guess there is nothing wrong with that. It will work fairly nicely like that. I was wanting to give a more descriptive message but that should be good enough. The registry API looks like it is a huge hassle to work with IMO so I am trying to avoid it or find it already encapsulated. I have found a few MFC classes but apparently nobody uses straight C++ for Windows programming anymore. Ohh well, thanks for the help.
|
|
|
|
|
KRowe wrote:
...apparently nobody uses straight C++ for Windows programming anymore.
Perhaps you meant that nobody uses straight C for Windows programming anymore. Technically, C++ knows nothing of Windows, so it is because of things like MFC, ATL, and WTL that Windows development is so much easier.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I'm not exactly sure what you are trying to say. If you are trying to say that technically MFC is C++ then yes you are correct but the MFC library is I think about 1.5 megs that I really have no use for until this little problem. So by straight C++ I meant C++ without additional huge libraries (I know that my includes add some extra baggage but it is still far less than MFC and I'm trying to minimize them as well). I guess that does sound a little too much like the common term "straight C" that is used to differentiate C from C++ but that is not what I meant.
I would have to argue with you about weather MFC would have made it much easier to do what I am doing however. All my program does is read a file and output it to the screen with some additional formating that requires me to output a single character at a time. This make the CString class almost useless for this. Additionally, I have no controls and only 2 very simple dialogs in the app (plus a Common Dialog). I guess it's what you're used to but, aside from the CString class and couple other handy features, MFC seems to be more of a hastle than it is worth. I can't tell you how much time I have spent trying to get MFC to not do something or other. True, it is the way to go for medium to very large apps, but for the smaller stuff (like my little text viewer) I prefer not to use it.
|
|
|
|
|
KRowe wrote:
I'm not exactly sure what you are trying to say.
It's a common misconception that C++ knows about things such as input/output, files, Windows, etc. I was simply clarifying that without extra packages such as STL, WTL, ATL, or MFC, what you are after is not possible.
KRowe wrote:
(I know that my includes add some extra baggage but it is still far less than MFC and I'm trying to minimize them as well).
Unless the code will be running on a cell phone or an older PDA, trying to optimize for size is not a worthy exercise. Thinking about "how big" the code is almost always leads to a lot of effort that produces no payback whatsoever. What matters is how big the data is. This goes back to the days when programmers were taught that "smaller is better."
KRowe wrote:
I would have to argue with you about weather MFC would have made it much easier to do what I am doing however. All my program does is read a file and output it to the screen with some additional formating that requires me to output a single character at a time.
With what you've described so far, I'm seeing a dozen lines of code, maybe two.
KRowe wrote:
This make the CString class almost useless for this.
I've never known CString to be useless for much of anything. Do you have an example?
KRowe wrote:
Additionally, I have no controls and only 2 very simple dialogs in the app
How can you have a dialog without any controls?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
How to obtain a CWnd* pointer for every control on a window?
|
|
|
|
|
First you have to enumerate all top-level windows with the EnumWindows() function.
Then you can use the EnumChildWindows() function to iterate through the top-level windows to get the window controls.
Hope it will help you...
Regards, mYkel
|
|
|
|
|
Thank you.
|
|
|
|
|
mYkel wrote:
First you have to enumerate all top-level windows with the EnumWindows() function.
Then you can use the EnumChildWindows() function to iterate through the top-level windows...
Both functions iterate through the top-level windows??
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Use EnumWindows() to get all top-level windows. Then use EnumChildWindows() to iterate through all childs of every top-level window...
Regards, mYkel
|
|
|
|
|
Or you loop through FindWindow and FindWindowEx which provide same functioality like EnumWindows and EnumChildWindows
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I am using _asm{...} inside a member function of a class. within the _asm{..} I am not able to access the member variables. The compiler generates an error "variable referenced but not defined".
Why is this happening?
USING INTEL COMPILER
CODE:
/////////////////////////////////////////
#include <xmmintrin.h>
#define A16 __declspec(align(16))
class SomeVar
{
public:
SomeVar();
~SomeVar(){};
A16 float xx[4]; A16 float yy[4]; A16 float ww[4];
void Update();
};
SomeVar::SomeVar()
{
for(int i = 0; i < 4; i++)
{
xx[i] = 1.0; yy[i] = 1.1; ww[i] = 0.0;
}
}
void SomeVar::Update()
{
__asm
{
movaps xmm0, xx
movaps xmm1, yy
addps xmm0, xmm1
movaps [ww], xmm0
}
printf("\n%f %f %f %f\n\n",ww[0],ww[1],ww[2],ww[3]);
}
SomeVar sv;
int main(int argc, char* argv[])
{
printf("XmmTest\n");
sv.Update();
return 0;
}
/* Generates error:
Compiling...
Xmm.cpp
D:\Cool\Xmm\Xmm.cpp(37): error: label "xx" was referenced but not defined
movaps xmm0, xx
^
D:\Cool\Xmm\Xmm.cpp(38): error: label "yy" was referenced but not defined
movaps xmm1, yy
^
D:\Cool\Xmm\Xmm.cpp(40): error: label "ww" was referenced but not defined
movaps [ww], xmm0
^
compilation aborted for D:\Cool\Xmm\Xmm.cpp (code 2)
Error executing xicl6.exe.
Xmm.exe - 3 error(s), 0 warning(s)
*/
-- Manohar
Scientist, Defence R&D.
INDIA
|
|
|
|
|
Inside of the Update() method, declare three local variables that hold the contents of the member variables. Then in the __asm block, reference the local variables.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
What is the efficient manner of maintaining an auto restart facility for an application. I have seen articles in net for running a windows service. But all the functionalities in those were from .NET. I want this feature using vc++ and MFC.
Thanks in advance
U Live And Let Others Live
|
|
|
|
|
hi all,
I want to disable all other Applications in the Screen when I open the MFC Dialog..(very much similar to shut down screen in the Windows)
How do I do that?...If any one know that ,please send a reply...
thanks.......
|
|
|
|