|
I have a (STL)string variable
str = " Data Data &newdata& &newdata&"
XML does not allow & in its Body for which I need to escape it using "&a m p;"
Now in this string i need to replace all &'s by "&a m p ;" and write to the xml file .
How do i use the STL string replace function ?
Please Help
|
|
|
|
|
this will do something like CString::Replace:
std::string::size_type pos = 0;
while( (pos = s.find(to_find, pos)) != std::string::npos )
{
s.replace( pos, to_find.size(), repl_with );
pos += repl_with.size();
}
(found on google, but i use it in my own stuff)
-c
Alcohol is the anesthesia by which we endure the operation of life.
-- George Bernard Shaw
|
|
|
|
|
I am trying to show the owner of a file so I wrote the code below
void CFileOwnerDlg::OnButton1()
{
UpdateData (TRUE);
PSID ppsidOwner;
PSID ppsidGroup;
PSECURITY_DESCRIPTOR ppSecurityDescriptor;
if (GetNamedSecurityInfo ((LPTSTR)(LPCTSTR)m_strFile,
SE_FILE_OBJECT ,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION,
&ppsidOwner,
&ppsidGroup,
NULL,
NULL,
&ppSecurityDescriptor
) == ERROR_SUCCESS)
{
char Name [2500];
DWORD dwNameSize = 2500;
char DomainName [2500];
DWORD dwDomainNameSize = 2500;
SID_NAME_USE peUse;
if (LookupAccountSid (NULL,
ppsidOwner,
Name,
&dwNameSize,
DomainName,
&dwDomainNameSize,
&peUse) != 0)
{
TRACE ("%s %s\r\n",Name,DomainName);
}
dwNameSize = 2500;
dwDomainNameSize = 2500;
if (LookupAccountSid (NULL,
ppsidGroup,
Name,
&dwNameSize,
DomainName,
&dwDomainNameSize,
&peUse) != 0)
{
TRACE ("%s %s\r\n",Name,DomainName);
}
LocalFree (ppSecurityDescriptor);
}
}
Whatever file path I input the trace always prints "Everyone"
I have searched msdn and it says "Everyone" is a pre configured group. But when I open User Manager administrative tool I can not see this group. Also for the files I have created I see again "Everyone" as the ownder. I think I should see my user name as the file owner instead of "Everyone".
Can someone please show me how to get the owner of a file.
Orcun Colak
|
|
|
|
|
|
I have a set of source code which are written in C on Unix. They are scattered in several directories and being compiled using a set of makefile.
My question is: how can I port them to VC++ 6.0? I want to keep the diretory structure.
As always, thanks a lot in advance!
|
|
|
|
|
MS supports unix makefiles more or less. You'll have to use the NMAKE batch and cmdline. See MSDN for further info.
If you are willing to have real MSDEV integration, then you'll have to write a small .dsp tool generator (directories and files). May be this exists already. Btw, with the MSDEV Add file dialog, you can select a whole set of files, thus it shouldn't be that hard to build the workspace. Of course, this doesn't bring the compiler options, linker options, ...
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
how can I let MSDEV know that it need to search every subdirectory for any *.h files?
I have a root directory as .\src
|
|
|
|
|
I wrote a simple program on UNIX to save a number 79.8 in a file. Then I ftp this file on system running Windows 2000. Now I tried to retreived data using fread() function. But I the number was no 79.8. Later on I wrote same program in Windows and now I obtained 79.8 with fread(). Then I viewed both files ultra edit and found that four bytes [floating point number] were written in different ways. I have forggoten the orignal patteren but it may be like this:
In Windows File : B1 B2 B3 B4
In Unix file : B3 B4 B2 B1
I will be thankful if some one can explain more.
|
|
|
|
|
sounds like a Big Endian and Little Endian problem.
one way to solve it is:
transfer the file in binary format, and do ntohs() or ntohl().
HTH.
|
|
|
|
|
Thanks.
I used CFtpConnection and CInternetSession classes to transfer file. How can I use ntohs() or ntohl().
|
|
|
|
|
The systems are using diffrent byte ordering (little endian and big endian are terms for it), it's given by hardware (CPU). If you need to use the file on both platforms, you have two possibilities:
- Choose one byte ordering and convert it on one of the platforms.
- Use text file.
Pavel
Sonork 100.15206
|
|
|
|
|
Dear all,
I tried to install network protocol driver in my VC++ application. But don't know which lib should add to the project for INetCfg COM interface, which are declared in NetCfgx.h
can anybody help me?
Thanks
Laura
|
|
|
|
|
If it is COM, you don't have to link to a specific library. You only need the definitions (in a .h or by #import ing it).
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
|
Old method with PCL could select it using a font ID.
File output direct to the port.
However now I am using a Printer DC and I dont have a CFont object to select.
How can I select the printer font in an MFC environment?
|
|
|
|
|
You can select a printer font inside OnBeginPrint() and OnPrint().
pDC->SelectObject(theFont);
Kuphryn
|
|
|
|
|
As I said.. I do not have a CFont object to select.
The font is only in the printers memory.
It is not a TrueType windows font and therfore cannot be loaded into a CFont object.
|
|
|
|
|
|
Look for Article on Microsoft site -> "How To Use Printer Device Fonts"
It might be of help, if you need to use Printer Fonts.
|
|
|
|
|
Does a larger executable always mean a slower program? I have a 2mb exe and it runs fine on my 1.4Ghz machine with 512mb of ram but is almost unusable on a PII 300 with 128mb of ram. It needs to work well on older machines due to marketing issues, does pulling parts out of the main program and into DLLs increase speed?
Ed
|
|
|
|
|
No, dividing your program to more DLL's doesn't help You You will need to optimize your algorithms or data structures.
Pavel
Sonork 100.15206
|
|
|
|
|
Your CODE is only using 2mb. But your DATA is using something between 128Mb and 512 Mb: let's suppose it's using about 300Mb. So, under this supposition, you are using a total memory of 302Mb.
If you divide your program in DLLs and do a pretty good (and hard) job maybe you can reduce your code memory usage by 50%. This means that your code could be loaded in 1Mb.
This means you reduced your total memory usage from 302Mb to 301Mb, after days of optimization. Does it suffice?
Do you see where you need to optimize?
My latest articles:
Desktop Bob - Instant CP notifications
XOR tricks for RAID data protection
|
|
|
|
|
Does the task manager correctly report the total memory used by the application? If so it only reports about 8mb used for my exe. If this is true then does my speed problem point to slow code?
Ed
|
|
|
|
|
|
What it is you are trying to do that needs so much memory? Forget the exe file size, and think abou the data you are tring to process.
Try and cut it down into chuncks. Using that much memory when you don't have enough on the smaller machine probably means you need to revise the way your processing your data. If you can, only load so much in at a time, and manage the swapping so that you have the most closely linked parts of data in memory at the same time to stop page faults.
I supsect that if you look at the task manager, the Page Faults and Memory Delta will be going mad.
|
|
|
|