|
The example you linked to uses zlib compression rather than zip compression, which is why it isn't compatible with winzip
The basic format of a self-extractor is actually pretty simple
What you need to do is write some code that can extract a zip archive from an address in memory
You then create an exe containing this code, and another small tool that takes a zip file, and merges the zip with the exe (i.e. just append the zip data to the end of your exe)
The exe needs to know where to look (i.e. at the end of the code), and extract the zip data from there.
As long as you keep the zip file intact within the self extractor, without modifying it, then winzip should still be able to find the archive and extract it manually
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Hi
I created a AdoDatabase connection in my service. But when the system is logged off or shutdown it shows OleMainThreadWndName error.
This happens only in NT not in 2000 or later.
Any idea will be greatly appreciated. I have been looking for this for quite some time
Thanks in advance
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
|
Hi
Thankyou Lim Bio Liong for your answer.
I have had a look at this. But this is not the problem. OleMainThreadWndName error occurs because one you initialize COM using CoInitialize it creates some windows for databases.
Now if the service is running and I try to logout, the system cannot close those windows. And throws of errors.
So my question is how can I overcome that.
Please Help me....!
Regards
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hello Zainu,
Sorry that the article did not help. I do have a comment that I hope will be helpful with your problem, this is summarised below :
>> one you initialize COM using CoInitialize it creates some windows for databases.
Yes, this is typical of COM, the windows that it creates are hidden windows and they are for sending hidden messages for COM objects in order to facilitate inter-thread method calls, etc.
However, I think it is safe to assume that these windows will not be of use once the COM objects behind them have been destroyed (once their reference counts have dropped to zero).
When you log out of the current windows session, your application should have Release()'ed all reference counts to COM objects. This should ensure that no hidden windows remain active.
My suggestion is therefore to see if there are any memory leaks in your application either in your service or in clients of your service.
Best Regards,
Bio.
|
|
|
|
|
Hi
Thankyou very much for your time.
>>When you log out of the current windows session, your application should >>have Release()'ed all reference counts to COM objects. This should ensure >>that no hidden windows remain active.
This is exactly my problem. How can I Uninitialize COM. My service should be running everytime.
Now the problem reduces to, How to handle CoInitialize and a Service. How to call CoInitialize within a service?
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hello Zainu,
Some comments I have at this time are as follows :
1. I get the impression that your service connects to the database on behalf of your client. If it is your service that connects with the database, my advise is to connect only when your client requests for it and to disconnect when your client app terminates.
2. Concerning calling CoInitialize() and CoUninitialize(), generally speaking, services service client requests in separate threads. A service normally creates a separate thread to service each client that connects with it.
Every individual thread must call CoInitialize() in order to make COM API calls. Every thread must eventually call CoUninitialize() before terminating.
So if you do need to call CoInitialize() and CoUninitialize(), call these in the individual threads of your service.
3. Please remember, Zainu, that the most important thing is to ensure that there are no memory leaks. Calling CoUninitialize() may not solve your problems if your interface pointer(s) messed up the reference counts.
To avoid such problems, always use ATL smart pointers and do not call Release() directly. Let the smart pointers take care of reference counts for you.
Hope the above helps, Zainu.
Best Regards,
Bio.
|
|
|
|
|
Hi
Thankyou again..
I will get back to you after following your instructiong. This time I believe your advice will be fruitful.
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hi
Thank you very much. At last I got over it...
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
from C++ header files to UML class diagrams?
Hi everybody
Currently I do have C++ header files with class definitions (member variables and methods), no source files with implementations yet, it doesn't even need to compile yet and everything is in "design phase". From those header files I would like to automatically generate a UML class diagram, with bells&whistles (and all the arrows like dependencies, aggregations, etc.), so I can nicely show my bosses my suggestion for that future class concept. Does anybody of you know such a program to generate UML from header files?
I know that you could do it with "Together Solo" since I already did exactly that, but the new company I work at is very small and the piles of bucks you need to buy "Together Solo" are very big ($3500+).
Since I basically want to make some UML class diagrams I (of course) tried tools like ArgoUML and DIA. ArgoUML looks quite nice, but it's not really "finished" yet and... well... it's made for Java: I wasn't yet able to define pointers to classes as class members - and I do love pointers and I do need them. DIA is more "drawing" than "syntax checking" but the whole application crashed several times at my computer - so I'm not impressed.
I want to add that I am a coder guy: I prefer to write down all the derivations and dependencies right into a class definition than to draw some lines and arrows into diagrams (those arrows I want to be generated automatically). I even need no automatic code generation. As soon as I am confident in my design concept and my bosses nod I will start to code it again from scratch anyway, with code commenting and such.
Any help very welcome!
Thanks & Bye,
Matthias / T.T.H.
|
|
|
|
|
Hey everyone!
I am stucking a bit with my coding!
I need to check an ASCII-file, that was read into ONE std::string for some keywords.
The code is running fine (checking front and end character for Separators (' ','+','.', ...)), I am only getting in trouble, if my keyword is at the end of a line.
Anyone an idea how to check this case?
cheers, thomas
|
|
|
|
|
It sounds like one of the separators needs to be '\0' or '\n' in addition to the others.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hey!
Thanks alot!
Everything is working fine now!
Good luck for your own code projects!
thomas
|
|
|
|
|
hello
i have made a hardware for pc.
now i want to make a software for it.
i need code in vb.net,vb, c++, or visual c++ for
accessing usb port.if someone now plz notify me
note that i have already implement hardware through
parallel port. and it is working 100% correct.
|
|
|
|
|
I have PLC.I send byte.
I use following function.
BOOL CSerialCom::WriteByte(BYTE bybyte)
{
iBytesWritten=0;
if(WriteFile(hComm,&bybyte,1,&iBytesWritten,NULL)==0)
return false;
else return true;
}
This function is work.
But PLC is not display.
I want to know
(This device is really send or not).
|
|
|
|
|
WriteFile returns TRUE if the function succeeds. In your function, you return FALSE when WriteFile succeeds . That's not really logical... So the problem is with the WriteFile function (and the arguments you are passing to it).
|
|
|
|
|
Out to confuse the newbies, hmm?...
Here is his code (rewritten for clarity ):
<br />
BOOL CSerialCom::WriteByte(BYTE bybyte)<br />
{<br />
iBytesWritten=0;<br />
<br />
if( WriteFile(hComm,&bybyte,1,&iBytesWritten,NULL) == 0 )<br />
{<br />
return FALSE;<br />
}<br />
else <br />
{<br />
return TRUE;<br />
}<br />
}<br />
And here is, some of, the documentation for WriteFile:
If the function succeeds, the return value is nonzero.
So, this is actually perfectly valid code...
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Ouch... I read it too fast I didn't see the '== 0'
|
|
|
|
|
as title
and how to convert back the decimal integer to a byte array in c++?
|
|
|
|
|
Hello Ting,
I assume that your byte array is 4 bytes long. This is assumed because a decimal integer in the Intel platform is 4 bytes long. If you are working in another hardware platform, change my code below to suit the integral byte size of that platform :
// To convert from a byte array to an integer :
#include <memory.h>
int ConvertFromByteArrayToInt()
{
unsigned char ucArray[4] = { 0xFF, 0xFF, 0xFF, 0x7F };
int iInt = 0;
iInt = *((int*)(ucArray));
return iInt;
}
// To convert from an integer to a byte array :
void ConvertFromIntToByteArray()
{
unsigned char ucArray[4] = { 0, 0, 0, 0 };
int iInt = 2147483647;
memcpy (ucArray, (void*)((unsigned char*)&iInt), 4);
}
Best Regards,
Bio.
|
|
|
|
|
Hello Ting,
I assume that your byte array is 4 bytes long. This is assumed because a decimal integer in the Intel platform is 4 bytes long. If you are working in another hardware platform, change my code below to suit the integral byte size of that platform :
// To convert from a byte array to an integer :
#include <memory.h>
int ConvertFromByteArrayToInt()
{
unsigned char ucArray[4] = { 0xFF, 0xFF, 0xFF, 0x7F };
int iInt = 0;
iInt = *((int*)(ucArray));
return iInt;
}
// To convert from an integer to a byte array :
void ConvertFromIntToByteArray()
{
unsigned char ucArray[4] = { 0, 0, 0, 0 };
int iInt = 2147483647;
memcpy (ucArray, (void*)((unsigned char*)&iInt), 4);
}
Best Regards,
Bio.
|
|
|
|
|
If I understand your question, the easiest solution would be to use a union . Something like:
union
{
BYTE b[4];
int n;
} u; Now if u.b were assigned values such as:
u.b[0] = 120;
u.b[1] = 86;
u.b[2] = 52;
u.b[3] = 18; Then u.n would have a value of 0x12345678. No "conversion" necessary.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks Bio~
However, i know the size of the byte array. So, do i convert it to a char[]?
and how to convert it?
|
|
|
|
|
Hello David,
That's a great idea indeed ! Using a union is absolutely brilliant !
I have a further suggestion :
union
{
BYTE b[sizeof(int)];
int n;
} u;
Instead of hardcoding the size of the array, I thought we could set this to the byte size of an integer. This code will ensure platform independence.
Thanks, David.
Best Regards,
Bio.
|
|
|
|
|
Hello Ting,
The size of the byte array must be exactly 4 bytes in intel platforms (4 bytes being 32 bits).
The reason why I use an "unsigned char" array is because a byte in programming terms is essentially an unsigned 8-bit character. So use "unsigned char" instead of "char".
If your byte array is smaller than 4 bytes, reset it to 4 bytes and pad the missing bytes with zero. E.g. :
instead of :
// Byte array to represent 0x00112233.
unsigned char ucByteArray[3] = { 0x33, 0x22, 0x11 };
make this :
// Byte array to represent 0x00112233.
unsigned char ucByteArray[4] = { 0x33, 0x22, 0x11, 0x00 };
Remember the byte ordering of Intel platforms : a two byte short integer with value 0x1122 is represented in memory bytes as :
0x22 <-- first byte.
0x11 <-- second byte.
Your byte array must not be larger than 4 bytes. This would be an error.
Best Regards,
Bio.
|
|
|
|
|