|
As your code is now, it's the responsibility of the caller to delete the memory the function allocates. This works, but it puts an extra burden on the caller and ties it to the implementation of the function.
A nicer way to do it is have the caller pass in a buffer and the size of the buffer, and have the function return the string in that buffer.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
Can you give me an example, please, please?
|
|
|
|
|
Sure!
bool TrimLeft ( LPCTSTR szOrigStr, LPTSTR szOutputStr, UINT uBuffSize )
{
int i = 0;
while ( isspace( szOrigStr[i] ))
i++;
if ( uBuffSize < (lstrlen(szOrigStr) - i + 1) )
return false;
lstrcpy ( szOutputStr, &szOrigStr[i] );
return true;
}
You'd call it thus:
{
TCHAR szOrigStr[] = _T(" foobar");
TCHAR szTrimmedStr[64];
TrimLeft ( szOrigStr, szTrimmedStr, 64 );
}
That way, the caller has control over the buffer. Most of the Windows APIs do it this way, so programmers are comfortable with it.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
Hi,
Here is my code to launch programmatically some net send commands :
if( !CreateProcess( NULL,
"Net.exe send COMPUTER2 Good morning" , NULL, NULL, FALSE, 0, NULL, NULL,
&si, // Pointer to STARTUPINFO structure.
&pi )) // Pointer to PROCESS_INFORMATION structure.
{
// I display here CreateProcess error message with GetLastError()
}
else
// OK Message is sent
This code work very well, but i dont know how to get errors messages.
For example under MS DOS windows if write the following command :
C:\>net send COMPUTER2 "Good morning"
The following error appear :
"an error is appear when sending message to COMPUTER2"
see NET HELPMSG 2273 for more....
CAN ANYBODY HELP ME HOW CAN I GET THIS ERROR PROGRAMMATICALLY ??
Thanks in advance
|
|
|
|
|
hi I have got some basic questions to ask : how to create a new .rc file with VC++ 6.0 and why the need to create a workspace(.dsw file)? Furthermore why the need to create a .dsp file.
|
|
|
|
|
DSP files are project files. They are similar to make files. They hold all the filenames and file dependancies for each name. Without a .dsp file, the compiler would only be able to compile one file at a time.
DSW files are for collections of DSP files. It stores project dependancies between projects. If you only have one project in a workspace, then it's kind of pointless.. but still necessary.
You create an .rc file by simply going to the Insert menu item and choosing "resource" It will create an RC file for you (If I recall correctly). You can't have more than one .RC file in a project (officially. Unofficially, you can create multiple .RC files and #include them in your main .RC file, but that's a pain and not well supported.)
The easiest way to create a new .RC file if you already have one is to create a new project and add one to that, then copy it to your ole project.
|
|
|
|
|
Now i need to complie my .cpp , .h & .rc files , so i need to put them in the same project and insert into a workspace to create a .exe file ? Is this what I should do ? Or can you reommend a good visual c++ book so that I can refer because I am very new to c++
|
|
|
|
|
Now i need to complie my .cpp , .h & .rc files , so i need to put them in the same project and insert into a workspace to create a .exe file ? Is this what I should do ? Or can you reommend a good visual c++ book so that I can refer because I am very new to c++
|
|
|
|
|
I have found more and more examples on how to copy text, bitmap, metafile, and any other type of data to the clipboard; but I can't find a simple example on how to copy a file to the clipboard and let Windows Explorer recognize it and paste it in a directory.
I have no shells but only the full-path file name.
|
|
|
|
|
Hi everybody,
is there an easy way to change the window caption font for modal or modeless dialog boxes?
I just want to change the font and want MFC to do the rest of the work, like drawing the text and
the min/max buttons etc..
TIA, Chris
|
|
|
|
|
There is code either on this site, or on www.codeguru.com (yuk!) that you could talor to your needs. Some change the background colour, and others allow more than one line of text. It's time for me to go home so I'm afraid you'll have to look for the articles yourself!
HTH
Jerry
|
|
|
|
|
No, there is no way to change the caption font and allow Windows or MFC to do the rest of the work for you.
There are, however, several classes available here and at codeguru to do this, to make it easier to implement.
|
|
|
|
|
Hi,
Can U hide the Scrollbars of a CTreeCtrl object? Help me.
Thanks in advance.
Ngo Khai Hoa
|
|
|
|
|
Add TVS_NOSCROLL style to the CTreeCtrl Object.
It is that simple.
Sundaravalli Shriram
Tektronix Engineering Development India Ltd,
Bangalore - 560001,
India.
|
|
|
|
|
Can anyone help me find information how make a view wityh look like outlook todaypage.
This view is like a html page.
thanks
|
|
|
|
|
It's not "like" an HTML page. It *IS* an HTML page.
|
|
|
|
|
Is there a method to export registry settings just like the one i used in regedit.exe? If yes, how to export programmatically?
Thanks all
|
|
|
|
|
visit http://zmanagers.chat.ru
you can find there Registry.cpp in sources.
I wrote there a function which makes this task.
Mike.
|
|
|
|
|
How can I create a virtual disk at RAM, and the disk should write all the contents to the physical disk file.
Any help are appreciate.
|
|
|
|
|
Hello all,
I recently wrote a security program with MFC that configured registry policies. The problem is that a script kiddie using a disassembler went right past my security measures by simply skipping to the place in the code that was past my password protected section. Is there a good way to protect against disassembers?
--Tale
|
|
|
|
|
If your security check is in code like this:
if ( !ShoudILetTheProgramRun() )
{ // show messages saying the app won't run
// and then exit
}
Then it's trivial to bypass. Don't make the security check that painfully obvious.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
Could you be a little more descriptive in your solution. I'm not familiar with disassemblers, so I really don't know what the weakness in my program is.
The way I'm checking for proper users is by reading an encrypted password from the registry and comparing it with what they supplied. If they are equal, I call the method to let them into the protected area. What are you suggesting I change?
--Tale
|
|
|
|
|
You'll have problems if you save password in the registry when OS needs to be reloaded. The password should be OS independent.
I collect 3 numbers from the environment:
1- Bios date
2- HD serial no
3- Program folder creation min+sec+milisec
They make up *almost* uniqe password.
Disassemblying is a different subject!
|
|
|
|
|
Could somebody give me a legitmate answer? The two posts here so far have been pretty useless to me. Sorry guys, but it's true. I felt that I explained it pretty well in my last post, so if you could answer it I would appreciate it. Here is what I wrote:
Could you be a little more descriptive in your solution. I'm not familiar with disassemblers, so I really don't know what the weakness in my program is.
The way I'm checking for proper users is by reading an encrypted password from the registry and comparing it with what they supplied. If they are equal, I call the method to let them into the protected area. What are you suggesting I change to make my program less suspectable to disassemblers?
--Tale
|
|
|
|
|
Look, there's almost nothing you can do about this. When it boils down to it. If the computer can read your assembly, so can a cracker. If the cracker can't, then neither can the computer.
All you can do is make it more difficult to find. put lots of code in there that does nothing and leads the cracker on false paths. Hide the code inside some other function, make it rely on a side-effect of the function, and don't just check the value of a memory location and exit. Go do a bunch of other stuff for no particular reason and exit somewhere unexpected.
That's all you can do.
|
|
|
|