|
Make sure this file exist on your system and can be found by the compiler (it should either be in the project directory or located in one of the "Additional Library Directory" (project settings -> "Linker" -> "General" -> "Additional Library Directory").
|
|
|
|
|
Ruchira Patel wrote: please give me any solution.
See here.
"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,
i am working on a simple application that needs to be updated frequently, do you have an an article that discusses how an application downloads the update then install it. Like an anti virus, it downloads the update definitions then install it on its own.
lets say its an application that collects updates from a common share-point.
lets not focus on the install part, what we want to focus is on the connection and download part..
and what are the common protocol and ports used for connection?
i got some good hint from Simon Ellis's article, An AutoUpdate Trick An AutoUpdate Trick[^], but i still can't find where is the download part,
any help or guide will be much appreciated, thanks in advance
|
|
|
|
|
loid grey manuel wrote: lets say its an application that collects updates from a common share-point.
I used a repository with version information, the application checks what needs to be downloaded. After successful download, checksum verification and unpacking the updater checks modification time on a per file basis, to decide which binary really needs to be replaced. If you plan to update multiple files, make sure they will be replaced together (to avoid dependency issues).
To my knowledge there is no simple automatic update mechanism on Windows, you probably need an extra executable for: stopping your application, replacing files and restarting you application again (all should be UAC compatible for Vista/Win7).
loid grey manuel wrote: and what are the common protocol and ports used for connection?
I did all network communication via HTTP, this means repository and downloads are on a web server.
Hope it helps.
|
|
|
|
|
Yup, it was a good hint for me, I've started reading books regarding your suggestions. since I don't have a personally owned database repository at least yet, and i only use free web hosting sites to store some of my files that i needed to access often.
thanks for the headstart, appreciate it.
but if you have a sample code or application for me to review the code, it would be easier.
thanks again,
|
|
|
|
|
If I use RegLoadKey() to load registry data from a hive, does the newly loaded data exist at the same time as the previously loaded data?
OR, does the previous data disappear, and only the new data exists under the predefined key?
For example, if I want to load information for a single COM server under HKEY_CLASSES_ROOT, will everything that was previously under that key still be there?
|
|
|
|
|
Richard Andrew x64 wrote: For example, if I want to load information for a single COM server under HKEY_CLASSES_ROOT, will everything that was previously under that key still be there?
Yes, unless you overwrite or delete it.
"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
|
|
|
|
|
Thanks, that solves a big problem.
|
|
|
|
|
I'm not sure if I've given the proper label to my issue, but I have upgraded to the new version of MinGW and am now having trouble compiling my code in Codeblocks. The program runs fine when executed from Codeblocks, but once I try to run it from windows I get an error stating that I need a certain dll file for it to run.
I found on a forum a linker option that has covered one of the required dlls but not all of them (-static-libgcc)
What linker options can I use to get rid of all these dependancies, I don't care how large it makes my exe; I think its easier to live with a large exe than having to package dlls with my project.
I appreciate any advise anyone has to offer.
|
|
|
|
|
It depends what the DLL is. If it's one you've got the source for rebuild it as a static library (archive in MinGW terms) and link against that instead. If it's not then it might be time to look for a replacement or get rid of the code that uses that DLL.
Cheers,
Ash
|
|
|
|
|
I have a string object called str. The content within is "Line1Line1\nLine2Line2\n". I can find the positions of '\n's using char array and use them like this str[10], but how to do this with string object. What is the function for this? I mean I know about string.find() and use it like this:
int n = 0;
n = str.find("\n");
but what if I want the second '\n'?
modified on Thursday, October 21, 2010 3:28 PM
|
|
|
|
|
What is "string object"? CString? std::string?
If it is CString, then as you can see in the documentation of CString::Find[^], you can specify it the starting character it will search from, so when n contains your first '\n', just feed find with n+1...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
TCPMem wrote: but what if I want the second '\n'?
Use the (incremented) last position as start for the next find():
std::string str = "Line1Line1\nLine2Line2\n";
for (size_t pos = 0; pos != str.npos; pos = str.find('\n', ++pos))
std::cout << str.substr(pos);
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
I need to pass an array into a procedure and return a string. The problem is the array could be 1, 2, 3 or 4 character strings.
I am stuck as how to do it, see typical arrays below.
char *OPTIONS_ENUMS[4] = {
"OPT_1",
"OPT_2",
"OPT_3",
"OPT_4"};
char *OPTIONS2_ENUMS[4] = {
"OPT_1",
"OPT_4"};
char* GetOptions(short nStatus, char* szOptions)
{
int i, nOptions;
nOptions = sizeof(ssmStatusOptions);
for(i=0; i < nOptions; i++)
{
if(nStatus == 0)
{
if(strcmp(szOptions[i], "NULL") == 0)
{
return "NULL";
}
else if(strcmp(szOptions[i], "ITEM1") == 0)
{
return "ITEM1";
}
else if(strcmp(szOptions[i], "NO_DATA") == 0)
{
return "NO_DATA";
}
}
else if(nStatus == 1)
{
if(strcmp(szOptions[i], "OK") == 0)
{
return "OK";
}
else if(strcmp(szOptions[i], "ITEM2") == 0)
{
return "ITEM2";
}
else if(strcmp(szOptions[i], "NO_DATA") == 0)
{
return "NO_DATA";
}
}
}
} How to call the procedure
e.g.
GetOptions(1, OPTIONS2_ENUMS);
where OPTIONS2_ENUMS is
char *OPTIONS_ENUMS[4] = {
"OPT_1",
"OPT_2",
"OPT_3",
"OPT_4"};
I need to know how many elements in the array and how to pass over the array. Its a c code project.
Many thanks.
|
|
|
|
|
You could either specify the array size to the function as an additional parameter, or you could terminate your array with NULL and in the function iterate until you get a NULL.
Btw, shouldn't this:
Andy202 wrote: char* GetOptions(short nStatus, char* szOptions)
be instead this:
char* GetOptions(short nStatus, char **szOptions) ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
Thanks for your suggestion. But are they anyway I can find out the number of elements in an array like this:-
char *OPTIONS_ENUMS[4] = {"OPT_1","OPT_2","OPT_3","OPT_4"};
for(int j = 0; j < 100; j++)
{
if(OPTIONS_ENUMS[j] == NULL)
return j;
}
|
|
|
|
|
No, this will (probably) fail; you only have 4 elements in your array so whatever exists at the next word OPTIONS_ENUMS[4] is not guaranteed, it may or may not be NULL . It is a simple matter to declare an array like this:
char *OPTIONS_ENUMS[] = {"OPT_1","OPT_2","OPT_3","OPT_4", NULL};
and let the compiler work out how big it needs to be.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I agree with Richard's answer - but in some cases, it may not make sense to use NULL as a sentinal marking end of the list, sometimes you may end up defining a non NULL sentinal ..
for example, in your list, as long as "EOL" or "End-List" we guaranteed never to be part of your data, you could look through the list until "EOL" or "End-List" were found
char *OPTIONS_ENUMS[4] = {"OPT_1","OPT_2","OPT_3","OPT_4", "EOL"};
but I'd stick with NULL unless you had a good reason (eg, NULL could be part of the data if you were specifying an empty option/slot)
'g'
|
|
|
|
|
See my comments to Alain.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
No it will crash, but
char *OPTIONS_ENUMS[5] = {"OPT_1","OPT_2","OPT_3","OPT_4"};
for(int j = 0; j < 100; j++)
{
if(OPTIONS_ENUMS[j] == NULL)
return j;
}
EDIT:
As Richard says in next post this may be error prone and is more a joke than a solution.
With C++0x (gcc 4.5 only for now) we can use the standard collections with initializer lists like:
std::vector<LPCSTR> OPTIONS_ENUMS = {"OPT_1","OPT_2","OPT_3","OPT_4"};
When not available (MS compilers for now) we must stay in C world and use a macro:
#define ARRAY_SIZE(_Array) (sizeof(_Array) / sizeof(_Array[0])) // This is the answer
char *OPTIONS_ENUMS[] = {"OPT_1","OPT_2","OPT_3","OPT_4"};
for (j = 0; j < ARRAY_SIZE(OPTIONS_ENUMS); j++)
{
if(OPTIONS_ENUMS[j] == NULL)
return j;
}
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Thursday, October 21, 2010 6:50 PM
|
|
|
|
|
Both yours and Garth's answers have the array size specified in the declaration, which I always feel is prone to errors in the future. If you add or remove an element or elements and forget to amend the size then your program starts misbehaving. Stick with my solution and let the compiler do the work for you.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
It was more a joke than an answer, I edited it to a real answer.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Thanks I just tested this and it did not work. The size is always 1.
Have I implemented it correct?
#define ARRAY_SIZE(_Array) (sizeof(_Array) / sizeof(_Array[0])) // This is the answer
char *OPTIONS1_ENUMS[4] = {"OPT_1", "OPT_2", "OPT_3", "OPT_4"};
char *OPTIONS2_ENUMS[2] = {"OPT_1", "OPT_4"};
char *OPTIONS3_ENUMS[1] = {"OPT_1234"};
char* GetOptions(short enumValue, char** szOptions)
{
int i, nOptions;
short size;
nOptions = 1;
size = ARRAY_SIZE(szOptions);
printf("Array Size = %d\n", size);
}
GetOptions(1, OPTIONS1_ENUMS);
GetOptions(2, OPTIONS2_ENUMS);
GetOptions(3, OPTIONS3_ENUMS);
|
|
|
|
|
Andy202 wrote: Thanks I just tested this and it did not work. The size is always 1.
Have I implemented it correct?
Nope
Use it as follows:
#define ARRAY_SIZE(_Array) (sizeof(_Array) / sizeof(_Array[0])) // This is the answer
char *OPTIONS1_ENUMS[] = {"OPT_1", "OPT_2", "OPT_3", "OPT_4"};
char *OPTIONS2_ENUMS[] = {"OPT_1", "OPT_4"};
char *OPTIONS3_ENUMS[] = {"OPT_1234"};
void GetOptions(short enumValue, char** szOptions, int Size)
{
printf("Array Size = %d\n", Size);
}
int main()
{
GetOptions(1, OPTIONS1_ENUMS, ARRAY_SIZE(OPTIONS1_ENUMS));
GetOptions(2, OPTIONS2_ENUMS, ARRAY_SIZE(OPTIONS2_ENUMS));
GetOptions(3, OPTIONS3_ENUMS, ARRAY_SIZE(OPTIONS3_ENUMS));
}
BTW you should not call your arrays OPTIONSx_ENUMS :
- as capitalized names are conventionnally reserved for C macros, and
- they are not enums but C arrays of const char* .
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Sorry for the late answer (went to bed, was night here), i agree with the others, use NULL or some special string (or a special pointer) to specify the end of the array.
Btw, you can also do this:
char *OPTIONS_ENUMS[] = {"OPT_1","OPT_2","OPT_3","OPT_4", NULL};
this way you don't have to specify the array size, your array's size will be determined by the items you enumerated.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|