|
Most likely the 32 bit EXE was given a local registry to play with, this is part of UAC legacy application handling.
The 64 bit EXE is not seen as a legacy application, and gets a proper slap on the fingers.
Usually it is during installation that one chooses what files should be opened with the application. Not something the application changes after installation.
|
|
|
|
|
I am confused with Imagelist_LoadBitmap. It certainly makes sense if we create an imagelist from ICON file(resource), because icon file can have multiple images.
But within Bitmap file, only one image can be contained. I wonder Imagelist_LoadBitmap always creates an imagelist initially with only one image contained?
|
|
|
|
|
When you create the image list, you specify the size of each image. LoadBitmap will divide the loaded image into appropriate sub-rectangles. The bitmap should contain properly sized images laid out horizontally.
|
|
|
|
|
How can I call 'ChangeString' from main and have the function change the passed char pointer to some other string value?
Thanks in advance.
#include <iostream>
using namespace std;
void ChangeChar(char* value)
{
*value = 'b';
}
void ChangeString(char* value[])
{
*value = "Changed!";
}
int main()
{
char c = 'a';
cout << c << endl;
ChangeChar(&c);
cout << c << endl;
char str[] = "Hello World";
cout << str << endl;
cout << str << endl;
system("pause");
return 0;
}
|
|
|
|
|
Technically you need a double pointer (a pointer to a pointer to char), you may use a reference:
void ChangeString(char* & value)
{
value = "Changed!";
}
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]
|
|
|
|
|
In the following line str is an array, not a pointer so it cannot be changed by the ChangeString() function.
char str[] = "Hello World";
If you change it to
char* str = "Hello World";
then it should work.
The best things in life are not things.
|
|
|
|
|
Actually this is bad practice.
This code is good:
char str[] = "Hello World";
This code is bad:
char* str = "Hello World";
The difference? In the first example str is allocated on the stack and you have full read and write access to it.
On the second, str points to a memory location containing the string "Hello World", but this memory could be allocated in a static (read only) section. Or consider a piece of code where you have this string literal multiple times. A compiler might decide to store it once and make all references to the string point to the same location. Then when you change it in one location it changes in all, but that wasn't your intention!
Instead, you should consider using a const char*, or if you want to modify it use string functions.
const char* str = "Hello World";
char str[200] = "Hello World";
|
|
|
|
|
Without knowing the intention of the programmer, neither of your suggestions is 'good' or 'bad'. Either way, it has little to do with the OP's question.
The best things in life are not things.
|
|
|
|
|
Unfortunately, it has everything to do with your answer and code. Even though the OP is obviously new to C/C++, it doesn't hurt to learn good practices right from the start.
At any rate, it wasn't a suggestion: it's me saying that it is bad practice to use pointers and string literals in that way, for the reasons I explained. This is quite independent of the programmer's intentions.
So my point is: your solution was almost correct, except for that you should use 'const char*' everywhere to work with it like this. This could potentially save the OP lots of time trying to debug weird access violation errors later on, as the compiler will be able to inform you when you are doing something inappropriate that you are allowed to do when just defining it as 'char*'.
Now if you think I am entirely wrong and that it is in fact not poor practice, then I'd love to hear your arguments.
|
|
|
|
|
The other answers tell you how it can be done.
But there is a risk factor here, in that the size of the buffer is not known to the ChangeString function.
So it is always safe to pass in a second size parameter and only copy that many characters to the buffer inside the ChangeString function.
|
|
|
|
|
The issue is about changing a pointer whose address is given, not copying into a buffer, so no length is necessary.
The best things in life are not things.
|
|
|
|
|
hy guys,
i built small program in c++ (mini Paint) using classes, stacks and vector with STL (all in vs2010)
i sent the .exe file from the \Debug directory to my friends (vs 2008) and they got error missing "MSVCP100D.dll"
tried to build .exe file with the release option, didn't help at all...
sorry if my english is not the best...
can anyone help me please?
thanks, udi
|
|
|
|
|
|
|
You can install the runtime library separately as suggested or you can include that in the EXE by selecting the /MT (Release mode) or /MD (Debug mode) option from Project -> Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library .
This will however increase the size of the EXE.
|
|
|
|
|
I made a transparent icon saved as png, and in vc resource compiler, I write the statement:
MyIcon ICON "myIcon.png"
But the compiler complained the png did not comply with 3.0 format.
|
|
|
|
|
A png image is not a Windows Icon resource
ID_PNG PNG "res\\Test.png"
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
#include <stdio.h>
#include <conio.h>
typedef enum {FUNK0=0, FUNK1, FUNK2, FUNK3, FUNK4, FUNK5, FUNK_N} F_ENUM;
class F;
typedef F_ENUM(F::* F_member_fn_ptr)(void);
class F
{
public:
F_ENUM F0(void) {printf("class F F0\n"); return(FUNK2);};
F_ENUM F1(void) {printf("class F F1\n"); return(FUNK3);};
F_ENUM F2(void) {printf("class F F2\n"); return(FUNK4);};
F_ENUM F3(void) {printf("class F F3\n"); return(FUNK5);};
F_ENUM F4(void) {printf("class F F4\n"); return(FUNK1);};
F_ENUM F5(void) {printf("class F F5\n"); return(FUNK_N);};
static F_member_fn_ptr FUNK[FUNK_N];
};
F_member_fn_ptr F_FUNKS[FUNK_N]=
{&F::F0, &F::F1, &F::F2, &F::F3, &F::F4, &F::F5};
int main()
{
F f;
for(F_ENUM i=FUNK0; i<FUNK_N; i=(f.*F_FUNKS[i])())
;
return(getch());
}
|
|
|
|
|
Are you inventing from scratch COM ?
Why do you need to access that way member function?
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]
|
|
|
|
|
I am a scientist and the stuff I do is a bit more complicated than inventing COM for myself.
But thanks for the help all the same.
|
|
|
|
|
There's nothing more complicated than COM, of course. Anyway you, being just a scientist, cannot understand it.
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]
|
|
|
|
|
This would be a recursive type: "A function that returns a function that returns a function that ...". You can't do that!
The question now is what you want to achieve with that? To me that code looks rather obfuscated, making it error prone and hard to maintain. The sequence of function calls is encoded in the function implementations, rather in the implementation of the calling function. This is not only breaking the concept of encapsulation, it is also prone to mistakes causing endless loops, and later changes such as introducing more of these functions or changing the sequence will be very hard.
Why do you not simply write a sequence of function calls instead?
|
|
|
|
|
Thank you.
I have two types of app that should use this concept:
1.)A sort of scripting language that drives big image processing routines where the next result is only decided on the basis of execution. So these things are a sort of super high-level assembly language in which instructions do not have locations, but which perform a jump as part of every instruction.
2.)Breaking down really big scientific executions so that they may be executed in fragments witin OnIdle etc.....
|
|
|
|
|
I'd solve these cases like this:
1) Make an interpreter that analyzes the script and determines which function to call next.
2) Just split the execution into individual parts and call them sequentially. If the individual parts work or continue to work on a common context, make a struct to hold that context and pass a pointer to that as a parameter to each part-function.
In both cases there is no reason at all to encode the sequence of function calls right into the functions themselves. In fact, it would be bad to do so, for the very reasons pointed out above.
|
|
|
|
|