|
Combine what I said about using front() and back() with what Johan said below about using c_str() to get a char* from a string.
MessageBox(0, m_lsFiles.front().c_str(), m_lsFiles.back().c_str(), MB_OK); Do not give up on STL. It is quite cool once you get use to it.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
BINGO!!! It worked
Thank you kindly sir
PJ Arends wrote:
Do not give up on STL. It is quite cool once you get use to it.
it seems really cool, just frustrating when working on a due project....when I just want to get done what needs to be done
Thanks again!!!
How do I print my voice mail?
|
|
|
|
|
Hockey wrote:
Didn't work for what i'm trying to do
Well, then, you should have stated what you were trying to do...
To get a pointer to a character buffer containing the text of the string object you use std::wstring::c_str(), as in
MessageBox(0, m_lsFiles.at(0).c_str(), m_lsFiles.at(1).c_str(), MB_OK);
--
The Blog: Bits and Pieces
|
|
|
|
|
I'm getting this error now
error C2039: 'at' : is not a member of 'list<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> >,class std::allocator<class std::basic_st<="" i="">
WTF am I doing wrong??
I'm really starting to dislike STL
Thanks for the help
How do I print my voice mail?
|
|
|
|
|
As PJ pointed out, std::list is not a random access container, which means it does not provide indexed access to items. I've been working too much with std::vector...
--
The Blog: Bits and Pieces
|
|
|
|
|
I am slightly confused by your question. When iterating the list, what difference does it make how many items are in it, be it 0, 2, or 100?
Show some code of what you have so far.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
It just didn't make sense to use a for loop or while, whatever to only get at the first and last item in the list....there will always only be two under this one condition...
How do I print my voice mail?
|
|
|
|
|
Friends,
I've developed a "Service" in Visual C++. Is start automatically during system boot up. Everything is fine.
But i want to set the dependency of this service. .i.e i want my service to start after another service "MSSQLSERVER" is started.
Can anyone tell me how can i do so. I think there is a function in service API to so so. But i dont know what function is it and how to use it ?
|
|
|
|
|
CreateService has a parameter for Dependencies:
SC_HANDLE CreateService(
SC_HANDLE hSCManager,
LPCTSTR lpServiceName,
LPCTSTR lpDisplayName,
DWORD dwDesiredAccess,
DWORD dwServiceType,
DWORD dwStartType,
DWORD dwErrorControl,
LPCTSTR lpBinaryPathName,
LPCTSTR lpLoadOrderGroup,
LPDWORD lpdwTagId,
LPCTSTR lpDependencies,
LPCTSTR lpServiceStartName,
LPCTSTR lpPassword
);
From MSDN[^]
lpDependencies:
[in] Pointer to a double null-terminated array of null-separated names of services or load ordering groups that the system must start before this service. Specify NULL or an empty string if the service has no dependencies. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all members of the group.
You must prefix group names with SC_GROUP_IDENTIFIER so that they can be distinguished from a service name, because services and service groups share the same name space.
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
I want to change exe file contents, while running it, i.e. the exe file should be able to change itself. Actually I want to append some data to exe, which I want to change dynamically, and save within same exe. I don't want to create a temporary file, or use system registary,or any other files. Somebody, please help!
Arsalan Malik
|
|
|
|
|
I don't think its possible to do that while its running. The solution I can think of might take a little work. Basically u write another app and insert the binary data for that app into a resource in your main app. Then you have a function that extracts the resource data using api calls and saves that file in a temporary folder, wherever. It then looks at the end of that file, and inserts the data that you want to change in your main app. Then it executes that program and closes itself. The extracted program then waits a second or two for the main program to end and then looks at itself and writes that data to the closed main program. Then it executes the main program again and closes itself. You can look it up, but I don't recall that you can write resources to the app you are executing the call from at runtime. And you definitely can't obtain write privilages to yourself while your running. Don't take my word for it though.
|
|
|
|
|
Polymorhpic EXE's
I always thought that would make more sense than storing INI data in INI files...
How do I print my voice mail?
|
|
|
|
|
Polymorphic exes are just viruses that rewrite their machine code every time they propogate. That has nothing to do with modifying a file that is in use.
|
|
|
|
|
Microsoft dosent support this.
|
|
|
|
|
You have several options and that depends on what you want to do.
If your objective is to hide some sensitive data than encrypt those into your exe, and decrypt at runtime.
If hiding the code from crackers eyes is what you are trying to achieve, try one of the different packers that are available (or write your own but requires some time. google for writing packer reverse)
SMC exe can achieve what you need to do, but that requires writing some assembly code (make sure the section in your exe your modifiying is linked with RW attributes)
So practically without knowing what you need, its kind of hard to tell you what to do.
An average cracker may only stop if he becomes bored to death
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
See if this article gets you started.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
i want to develop a port scan detector...
can any1 help me on this...
how to do it???
|
|
|
|
|
We wont develop your program for you. I suppose you could monitor the ports for connections, but then when you put nMap portscanner into the picture it might get a little harder. nMap doesnt actually try to connect to the port to see if its open. I think it uses arp requests or something, its been awhile since i used/read about it. So that will require some more programming.
|
|
|
|
|
I didn't think that nMap detected port scanning, rather it used various port scanning techniques to Map the network!?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I never said nMap detected portscanning. I meant that trying to detect nMap portscans would be hard.
|
|
|
|
|
Sorry, I misunderstood your post. You are quite right. nMap uses various port scanning techniques most of which would need so sort of packet analysis (pattern matching) in order to detect them.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
A suppose a solution would be to either write an NDIS driver of your own or use WinPCap[^].
You could then analyse the incoming packets for patterns that would suggest a port scan is happening.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I read this about using a wrapper for Non-Static Callbacks within a class. (http://www.codeproject.com/cpp/SetTimer__non-static.asp) Its brilliant. I can't believe I never thought of it. Anyway, would it be possible to use a Non-Static callback with threads? I want to run another thread within my class using CreateThread, but I want the thread to be able to access the members of my class. Is it possible?
|
|
|
|
|
I believe you can use a similiar approach such as:
Let's say Class A is the class that you want to access from within the thread. Then you can do something like:
in A::something() : (if you're using VC++)
AfxBeginThread(fnThread, this);
in fnThread(LPVOID param) :
A* pObj = static_cast<A*>(param);
then you can access A's methods like:
pObj->aMethod();
of course, provided you have the required access level for it.
|
|
|
|
|
Right now I decided to use the multimedia timers to call my drawing routine, and the callback doesnt support and void user-defined params. So I figured out all I really need to do is name a pointer of type of my class static and put it in the class declaration like so:
static CScroller * ClassPtr;
So now my static wrapper callback can access it and use it to call the non-static member function that does all the drawing work. What a nice little hack. I love it. Anyway as I was reading that article i mentioned earlier from the code project, I noticed how just having "static CScroller * ClassPtr;" in my class declaration would cause an undefined external object linking error. The article mentioned putting "CScroller * CScroller::ClassPtr;" in my class implementaion. That fixed the error. What I want to know is how does doing that fix it and why does it get that linking error if I don't put it?
|
|
|
|