|
for that error it was the " that i added to the path when including the lib. now it's gone when i erase it
For the oci, i m trying to put on screen the data from an Oracle DB using C++ and this to integrate it into a larger team work. so my part is to begin with the ocilib driver.
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
Hi, I am a C++ beginner. I have an NT Service I need to publish on the net for download but I don't want any one to be able to start except me or the one I authorize. When you download the service executable you could install the service but you should not be able to start it. One of the ideas is to protect the service executable with password, this way, in theory, only the one who has the password can start the service. Lots of EXE Password protectors on the net, but once I use one of them to protect the service executable the service doesn't start at all. The reason is obvious; NT services has no message pipe a user could use to enter the password. I even used Themida to protect the service as described on their KB (they say their software can protect NT Services) but looks like Themida actually corrupts the service executable too as it doesn't start anymore. I have the source code of the service and I use [service /i] and [service /u] to install/uninstall the service, but I don't know how to pass the password as a command line parameter to the service when I start it. the SCM attempt to start it.
If the password protecting is a bad idea, could some one guide me on how to reach my goal, my goal is: my service should not be started by anyone except me.
Thanks
modified on Sunday, May 23, 2010 3:52 PM
|
|
|
|
|
Hi,
Not sure if this helps as an idea, but if you decouple the concepts of "service start" and "service can do something useful" you might find another way into the problem.
So when the service first starts up it just sits there, doing nothing. It rejects all requests over it's external interface (over RPC, TCP, shared memory) until something comes along and tells it to activate. The thing that tells it to activate is another, fairly small, application that's password protected. Only the person that knows the magic mantra to get the activation process running (i.e. it's password) can switch the service from dormant to active.
There are some problems with this approach:
- Securing the link between the thing doing the activation and the service. Quite how you sort the trust out to stop some bad guy reverse engineering your protocol could be an interesting challenge.
- if the service has to do something before the first interactive user logs in then this won't work. Sorry, back to the drawing board!
Hope this provides some food for thought,
Cheers,
Ash
|
|
|
|
|
Delicious food Ash, thanks, but unfortunately, my service should do the hard job before user logon, which means it should rely on itself on the matter of being active/inactive.
from your post I understand that a service password protecting is not good, but I need to know; is it possible? The guys at Oreans say that it's possible and their product could do it without even having the source code of the service but it doesn't work! any ideas? thanks
|
|
|
|
|
Oh well, forget my post then
I have no idea why your third party product doesn't work. I'd wave the prospect of an order at them and see if that makes them sort out your problem, it often works for me!
Cheers,
Ash
|
|
|
|
|
I did, I contacted them and literally said: "This problem is the only reason why I will not order your product", I'm still waiting for their response!
Thanks
|
|
|
|
|
I have the following code:
....
private:
void __fastcall WMQueryEndSession(TWMQueryEndSession& Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_QUERYENDSESSION, TWMQueryEndSession, WMQueryEndSession)
END_MESSAGE_MAP(TForm)
.....
void __fastcall TForm1::WMQueryEndSession(TWMQueryEndSession & Message)
{
Message.Result=0;
}
Compiled by C++ Builder 2010, the code works improperly. Although it prevents the computer from shut down, but it also closes my application. The code below fixes the problem, but it is not stable (sometimes does not work) and the such long delay in 10 seconds is not acceptable in my case:
void __fastcall TForm1::WMQueryEndSession(TWMQueryEndSession& Message)
{
Sleep(10000);
Message.Result=0;
}
Does enybody know how to fix the problem? Thanks.
|
|
|
|
|
I had a simular problem and had to check for 2 messages WM_ENDSESSION or WM_QUERYENDSESSION. Then set a flag to indicate shutdown, this flag was then used in an OnClosing event that by default cancelled the close to minimize to the system tray
|
|
|
|
|
ARopo wrote: I had a simular problem and had to check for 2 messages WM_ENDSESSION or WM_QUERYENDSESSION. Then set a flag to indicate shutdown, this flag was then used in an OnClosing event that by default cancelled the close to minimize to the system tray
Thank you for your answer. Hovewer your suggestion will not work in my case as WM_ENDSESSION is calling Application->Termiante() which terminates program even if the flag in OnClose event is set to hide or none and the application is minimized to the systray. Calling Application->Termiante() by WM_ENDSESSION (even if application returns zero to WM_QUERYENDSESSION message) is recent bug of C++ Builder 2010. Previous versions of the compiler worked properly and did not call Application->Termiante() if application returned zero to WM_QUERYENDSESSION message. Does anybody know how to fix or bypass this bug of the C++ Builder 2010?
|
|
|
|
|
Hi,I would like to know how can I create various string from some given characters eg:
given characters: a, b
I would like to generate the following strings:
aa
ab
ba
bb
What I have thought of is having (for 2 inputs only) two for-loops one inside another, and then loop each to the number of inputs which in this case is 2 and the output strings will be 2*2 0 4 strings and as the number increases the number of output strings will increase by multiplying n*n (n-times)
|
|
|
|
|
|
Sounds like home work, but I'll explain it any way.
This is a simple binary example; where 'a' implies bit not set and 'b' implies bet set.
Possible solutions:
for( int i = 0; i < 4; ++i )
{
if( 2 & i )
std::cout << "b";
else
std::cout << "a";
if( 1 & i )
std::cout << "b";
else
std::cout << "a";
std::cout << std::endl;
}
OR
char c[2] = { 'a', 'b' };
for( int i = 0; i < 4; ++i )
{
std::cout << c[1 & (i>>1)];
std::cout << c[1 & i];
std::cout << std::endl;
}
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
|
|
|
|
|
ok, thanks for your reply. First this not a homework, this is an idea that came to my mind and tried to implement it yet I failed ...
what I understood from your solution is that it will work with just two inputs, but I want to work with various number of inputs as I stated before ...
I was thinkin of making the size of the string constant and then generate strings using the input characters to generate the strings under one constraint, the size of the string should be less than or equal to the number of input elements ... I`ll try to implement it using you sample solution ...
Hope my question is more clear now ...
|
|
|
|
|
The first thing to recognise is that when you're generating your strings you're just counting. Represent a by 0 and b by 1 and your example is:
00
01
10
11
And if you had three letter, a, m, z you could represent them by the digits 0, 1 and 2:
000
001
002
010
011
012
020
021
022
100
101
102
110
111
112
120
121
122
200
201
202
210
211
212
220
221
222
You're counting in base 2 in the a,b case, base 3 in the a,m,z case.
So you're going to get a number of solutions equal to the number of letters raised to the power of the number of letters - this gets big real quick. 4 letters has 256 combo, 5 letters has 3125 and so on.
For a brute force approach "all" you've got to do is:
- generate and the integers in the range ]0, n raised to the power of n]
- convert each number into a string of digits in base n
- convert each string of digits into a string of characters
This is one use of std::generate_n and two uses of std::transform.
With a bit more care you can collapse all three into call of std::generate_n with a bit of class building. I've wittered on enough for now - if you'd like more information just shout.
Cheers,
Ash
|
|
|
|
|
In VS 2008 it complained about the need of the newest windows SDK.
I've installed VS 2010 which is shipped with v7.0 but Intel Compiler still complains.
Is there newer than VS 2010 SDK available?
Чесноков
|
|
|
|
|
Hi,
I a bit confused to use OLE service for Crichedit
I use the SetOleCallBack to set the pointer ???
If yes
then What is GetIRichEditOle all about
thankx
|
|
|
|
|
Hi all,
1) Can we use free() function to free the memory allocated by "new" operator.
2) Can we "delete" operator to delete the memory allocared by malloc() function.
Thanks in advance
sAI
|
|
|
|
|
new and delete can be overloaded, so generally speaking, you can't do that.
|
|
|
|
|
You shouldn't. It may or may not work, depending on the implementation.
Steve
|
|
|
|
|
The short answer to both these questions is: No, never, ever, ever, ever mix calls to new/delete and malloc/free.
The long answer is that, unlike malloc and free, new and delete don't allocate and release memory, they create and destroy objects. If you try and free an object created by new the destructor for the object won't be called, if you malloc a block of memory the constructor for whatever type you assign the pointer to won't be called.
Cheers,
Ash
PS: In case I haven't said it strongly enough, don't do it. Really. Future generations of maintenance programmers will curse your name if you try it.
|
|
|
|
|
These methods are to be used in pairs and you should not mix them.
If you allocate memory with malloc then you need to free it with free . The same goes for new and delete .
C Memory Functions
malloc : Allocates an uninitialized block of memory, given the number of bytes.
calloc : Allocates a zero initialized block of memory, given the number of elements and the size of the element.
free : Deletes the memory allocated by malloc or calloc .
C++Memory Operators
new : Is an operator that allocates storage for one or more elements (objects) and then calls the constructor of each element to initialize it.
delete : Is an operator that calls the destructor for each of the stored elements and then frees the associated storage.
As you can see from the above, new is not equivalent to malloc and delete is not equivalent to free . They are not enterchangable and should not be mixed. When writing C++ code you should use new and delete , unless you have a very good reason not to.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
|
|
|
|
|
If you try to write a code, using this option it will compile but at run time the
1) Combination of malloc and delete get crashed
2) If you allocated memory for object using new and try free for deallocating memory there will be memory leakage problem because destructor never call by free
|
|
|
|
|
Combining malloc and delete might not cause a crash - with a couple of the compilers I use I'm pretty sure I can write code that allocates memory with malloc and deletes an object where that block was allocated without a crash. I shouldn't though as it requires a lot of knowledge of how the compiler's runtime works and is about as portable as a suitcase of bricks.
Likewise if I call free on an object I created with new I might not get a memory leak. Yes, the destructor won't be run but the destructor isn't the thing that releases the primary memory of an object.
Ash
|
|
|
|
|
Hello
sry for may bad english im a Austrian
Ok now my question
I have a litle Prog witch opens a txt file from my local hdd, now i want to open a txt file from my web serv and put it out on te consol.
But how can i open the file ?
it doesn't work
ptr = fopen("\\http://king.ath.cx//server.txt" ,"r+");
if(ptr == NULL) {
printf("\nfopen error\n");
getchar();
Lg
Alex
|
|
|
|
|
You must first copy the file onto your local disk, either through your browser or via FTP.
It's time for a new signature.
|
|
|
|