|
Thank you Cedric...
"....I think there are some such classes on this website....." you mean on code project?
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Programm3r wrote: "....I think there are some such classes on this website....." you mean on code project?
Yes of course. Take a look here[^] for example (there are some other, just do a search in the articles in the MFC/C++ category).
|
|
|
|
|
Many thanx Cedric .... I appriciate the help
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Programm3r wrote: [Category A]
filename = file1.txt
fileExtension = txt
[Category B]
ipAddress = 192.168.0.1
portNumber = 101
So how can I access only the parts within the file that is useful??
This is the format of a .ini file. Use functions like GetPrivateProfileString() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello
on visual c++ 6
my pb is:
when I create a std::map in an exe and pass it to a object's method in a DLL, I can't access to the elements of the map (it crashs after the first access).
You can try this minimal code illustrating that.
the code: a main.cpp file: the "application".
dll.h and dll.cpp : the dll with the object's method:
main.cpp___________________________
#pragma warning( disable: 4786 )<br />
<br />
#include <map><br />
#include <iostream><br />
#include <string><br />
#include "dll.h"<br />
<br />
int main ()<br />
{<br />
std::map<const std::string, std::string> l_map;<br />
std::map<const std::string, std::string>::iterator it;<br />
int i;<br />
<br />
l_map["1"] = "2";<br />
l_map["3"] = "4";<br />
l_map["5"] = "6";<br />
<br />
for (it = l_map.begin(); it != l_map.end(); it++)<br />
{<br />
std::cout << (*it).first << ": " << (*it).second << "\n";<br />
}<br />
<br />
CDll obj;<br />
obj.f(l_map);<br />
<br />
std::cin >> i;<br />
return 0;<br />
}
dll.h________________________________________
#pragma warning( disable: 4786 )<br />
<br />
#include <map><br />
#include <iostream><br />
#include <string><br />
<br />
#ifdef DLL_EXPORTS<br />
#define DLL_API __declspec(dllexport)<br />
#else<br />
#define DLL_API __declspec(dllimport)<br />
#endif<br />
<br />
class DLL_API CDll<br />
{<br />
public:<br />
void f(std::map<const std::string, std::string>& p_map);<br />
};<br />
dll.cpp________________________
<br />
#include "dll.h"<br />
<br />
void CDll::f(std::map<const std::string, std::string>& p_map)<br />
{<br />
std::map<const std::string, std::string>::iterator it;<br />
<br />
for (it = p_map.begin(); it != p_map.end(); it++)<br />
{<br />
std::cout << "DLL: " <<(*it).first << ": " << (*it).second << "\n";<br />
}<br />
}<br />
Thank you in advance for your help.
Nico
|
|
|
|
|
Are both the DLL and the exe using the same runtime library ? You can check in your project setting -> C/C++ -> Code Generation -> Runtime library (for VC2005)
|
|
|
|
|
Oh ! you are here, too.
I tried to reproduce crash. But, no success.
May be problem is what Cedric is saying.
|
|
|
|
|
This is a known problem in the STL that comes with VC++6.0. See KB articles Q172396 and Q168958 for more details. In a nutshell, this has to do with how that STL implementation uses static data.
There are alternate STL implementations (like Dinkumware) that do not have this problem. At least, I think the old Dinkumware one you used to be able to purchase.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Both Cedric and James are right. There are two problems with your approach:
1) The version of STL you are using is broken. You can try fixes available here[^]: or pick some other implementation of the Standard Library that works with VC6.
2) Even when you get a good STL implementation, you'd better ensure that all the modules use the same instance of the CRT.
In short, I think it is a good idea to follow Herb Sutter's advice and make the dll entries C (not C++) functions.
|
|
|
|
|
Nemanja Trifunovic wrote: In short, I think it is a good idea to follow Herb Sutter's advice and make the dll entries C (not C++) functions.
I don't recall ever seeing Sutter saying that. Do you have a reference for it?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
I'll go back and re-read my copy to make sure. The reason I ask is because Sutter (along with Meyers) usually write about platform independent coding styles, so it would be unlike him to mention something specifically about DLLs. Especially since the same limitations are not placed on .so's in the *Nix world.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: I'll go back and re-read my copy to make sure.
I think you'll find it in the item 63. Use sufficiently portable types in a module’s interface. or somewhere around it in the Namespaces and Modules part of the book.
|
|
|
|
|
Hi,
Recently I started working in VS2005 instead of VS6.
In VS6 I could add member veriables to my class by using the class wizard.
In VS2005 I'm able to add only one member veriable at a time(i.e - for each
member veriable i need to right click over the form , choose the Add veriable , add the member veriable and choose the finish option(I can't add more than one veriable in one session).
Is there another quick way to do so?
Regards,
Eli
|
|
|
|
|
|
|
eli15021979 wrote: s there another quick way to do so?
Open the class' .h file and start typing. It's the fastest and easiest way to add member variables.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
When you click the class in class sheet, you'll see a property sheet. It is like the class wizard for adding message handlers and overwriting virtual functions.
If you use Dialog DDV/DDX, the adding variable members is for it.
|
|
|
|
|
I am about to have a go at writing my own service application. But before I start, I have a few questions I have unable to find reasonable answers to.
An article on CP states that a service is loaded at boot time before any users log on to the system. The service I intend to create is dependant on some system variables to be set which means the user is required to be logged on. This leads me to my question. Since the service requires the user to be logged on, I also want to be able to configure it for each user, which would probably require reading some HKCU registry keys. But how should I handle the case where more than one user is logged on, would the service be run as a seperate instance?
When installing the service, is it possible to do so without admin privlages?
|
|
|
|
|
The service runs in the context of a user so HKCU registry keys are of little/no help.
Running as a separate instance I don't think is possible.
Is there a way you can communicate with the service when a user logs on and send it the variables
it needs?
Otherwise, it sounds more like an app that runs in the background from the users Startup folder situation.
WalderMort wrote: When installing the service, is it possible to do so without admin privlages?
No.
Mark
|
|
|
|
|
Hi,
I wish to create .msg file by using Api calls without using MAPI...I have
all the details of mail item which can be get from .eml file...
Please suggest me where i can get the info for creating .msg files
without using MAPI and any third party tools should not be used...
Regards,
nag.
|
|
|
|
|
Hi,
I'm currently writing a small server application for data transfer. Two commands are for direct file transfer (relative path, e.g. test/data.dat) and I want to limit the filenames to be in the directory and subdirectories of the server application.
Let's say the server lies in c:\server\server.exe, now I want to be able to e.g. put a file into c:\server\new folder\test.dat, but not outside the server directoy, e.g. c:\test.dat (e.g. with a ../test.dat or new folder/../../test.dat).
Is there a good way to parse bad filenames/path?
Greetings
|
|
|
|
|
It is not clear what you need to do. I don't know what a "bad filenames/path" is. I am not sure if you must recognize incorrect syntax of if you need to allow access to something and not allow access to other things.
File access is typically controlled using the built-in features of the NTFS.
|
|
|
|
|
Per your subject, you need to read up on Access Control List (ACL). There's a whole API for it.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
One way, if youv'e got absolute paths, just compare them as strings/char arrays.
You can get absolute paths by using _fullpath() or _wfullpath.
Then you can do the compare, something like this (beware! Old C syntax here):
NOTE! I didn't find the time to set current directory to c:\server before testing the code, so I made a full path name for goodRelPath. Else, I could have used a relative path for goodRelPath.
char * projectDir = "c:\\server\\";
char * goodRelPath = "c:\\server\\new folder\\test.dat";
char * badRelPath = "c:\\test.dat";
char tempFullPath[MAX_PATH];
_fullpath(tempFullPath, badRelPath, MAX_PATH );
if(strstr(tempFullPath, projectDir) == projectDir)
{
}
else {
}
_fullpath(tempFullPath, goodRelPath, MAX_PATH );
if(strstr(tempFullPath, projectDir) == projectDir)
{
}
else {
}
-- modified at 0:43 Tuesday 12th December, 2006
Better code...
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|