Copy constructor
Hello,
I have a class that has a pointer to another class as a private member
variable. I now want to create a copy constructor for this class and I
don't get it.
class myClass
{
int m_x;
yourClass * m_yObj;
myClass(myClass* mobj);
};
myClass::myClass(myClass* mobj)
{
m_x = mobj->m_x;
m_yObj = ?????
}
How do I create a deep copy of the m_yObj object? I want new object with
the same values
// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English! Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277423
Interface to external hardware
We are developing some hardware which uses a 1-wire bus. The bus
requires pulses of 10us +/- 15%.
There seem to be 3 ways to interface the hardware to a Windows XP PC.
1) (favoured option of hardware team) Small piece of level-shifting
hardware, shareware parallel port driver, Windows application which
does bus timings. (Software team say there is no chance of achieving
required timings in user-mode program).
2) (favoured option of software team) Do all timing critical stuff in
a PIC. PIC adapts between PC and 1-wire bus. Talk to PIC from PC via
RS232.
3) Write custom parallel port driver. Do timings here (at ring 0).
Windows application simply passes data to/from driver and does no
timings.
As Windows developers what do you think of options 1 & 3. Are they
likely to achieve the required timing accuracy? How do they compare
with the effort of 2? (Assume PC will be dedicated to the task of
communicating with the hardware device, i.e. no other apps running,
but otherwise standard desktop PC connected to network etc.)
Thanks in advance,
KK Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277422
Copying files using Winsock 2.0 and the IOCP
Copying files using Winsock 2.0 and the IOCP
I am copying files from a server to clients using the IOCP technology.
I have this proceeding full tested, and it is working well.
I am having some problems, just in some computers.
In some computer, apparently with the same configuration and with same OS,
the copy are very very slowâ?¦ one two minutes for just some kbâ??s (when I copy
the file directly in network between server and those computers the speed is
normal).
In other computers the speed is always normal.
All computers have the same antivirus, and similar programs installed.
What could be slowing the speed in some computers?
Thanks.
Rui Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277407
string convertDoubleToString(double d)?
I would like to find a simple method for converting a double to a string,
almost as simple as:
string convertIntToString(int i)
{
stringstream ss;
string str;
ss << i;
ss >> str;
return str;
}
without having to specify how many digits the double number has after the
decimal point.
Please help! Thanks! Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277397
Inherit class in library
Hello,
I have a 3:rd party library(dll) which contains a class xPolygon that I
want to inherit.
I have done this:
#include "xPolygon.h"
class myPolygon : public xPolygon
{
...
}
But I get an error:
1>e:\projects\xlaser1.2b\inc\xpolygon.h(51) : error C2470: 'xPolygon' :
looks like a function definition, but there is no parameter list; skipping
apparent body
The xPolygon class looks like this:
#define XOBJECTS __declspec(dllimport)
class XOBJECTS xPolygon
{
private:
xVectorList* x_pVectorList;///< Vectorial data
public:
/// Attaches a list of data to the polygon
void AttachVectors(xVectorList* pList);
/// Detaches data list from the polygon
xVectorList* DetachVectors();
/// Returns the vectorial data list
virtual xVectorList* GetVectorList(void);
/// Returns the data list length
virtual int GetVectorCount(void);
public:
/// Construct an xPolygon instance
xPolygon();
/// Construct an xPolygon instance initializing from a given polygon
xPolygon(xPolygon& poly);
/// Default destructor
virtual ~xPolygon();
...
}
Please help!
// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English! Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277394
fprintf performance
Hallo,
I am using fprintf to write a very large byte-array to disk.
In order to do this, I am writing each byte with a separate
fprintf-call in a text file (text file is a hard requirement
for my application).
Unfortunately, the performance of this disk-write is very poor:
over all, I do get only ~17Mbit/s, which is not acceptable
for my purpose.
How can I speed up my application? Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277393
modifying wcout
I wonder if it allowed to modify wcout. For example to write all wcout
output to a buffer during a function call, how to do this?
wchar *x;
// setup wcout to write to buffer x
my_function();
// reset wcout
thanks Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277389
[OT] IDA SDK (determine segment size using C++)
Hi,
I'm on the IDA SDK and I am building my own disassembler.
I have an off-topic question is that how can you retreive a current segment
size whether it is 16-bit or 32-bit?
if there is no one here knows IDA, how can I just get it using C++ functions
or using the assembler language?
Thanks Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277386
problem in creating Services
Dear all,
As i start a service.
It will start in system as a user account .
but i need it will start as a current login as a user.
what i have done
DWORD dwDesiredAccess = SC_MANAGER_CONNECT |
SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_QUERY_LOCK_STATUS |
STANDARD_RIGHTS_READ ;
if ((schSCManager = OpenSCManager(NULL, NULL, dwDesiredAccess)) ==
NULL)
{
nReturnCode = GetLastError();
}
else
{
SC_HANDLE schService;
if ((schService = OpenService(schSCManager, pszServiceName,
dwDesiredAccess)) == NULL)
{
nReturnCode = GetLastError();
}
if (!StartService(schService, 0, NULL))
{
nReturnCode = GetLastError();
if (nReturnCode == ERROR_SERVICE_ALREADY_RUNNING)
nReturnCode = ERROR_SUCCESS; // not an error
}
}
but it will start this service (pszServiceName) with SYSTEM as user
name
but i need it should start with current login user
thanks in advance.
Edit/Delete Message Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277377
Compiler bug: error C2839 when operator-> returns pointer to built-in type
When operator->() returns a pointer to a built-in type (e.g., char), it
doesn't work properly on either VC++ 2003 or VC++ 2005. The following
valid C++ program is rejected by VC++, saying:
error C2839: invalid return type 'C *' for overloaded 'operator ->'
//////////////////////////////////////////////////////////////////////
typedef char C;
template <typename T>
class SmartPointer {
T * m_ptr;
public:
T * operator->() const {
return m_ptr;
}
SmartPointer(T* arg) : m_ptr(arg) {
}
};
int main() {
C* rawPtr = 0;
SmartPointer<C> smartPtr = 0;
rawPtr->~C(); // Okay :-)
smartPtr.operator->()->~C(); // Okay :-)
smartPtr->~C(); // error C2839!!! :-(
}
//////////////////////////////////////////////////////////////////////
Is this a known bug? I didn't find it at
https://connect.microsoft.com/VisualStudio/feedback
FYI, the thing is relevant to the resolution of C++ Standard Library
issue 659, "istreambuf_iterator should have an operator->()"
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#659
Kind regards,
--
Niels Dekker
http://www.xs4all.nl/~nd/dekkerware
Scientific programmer at LKEB, Leiden University Medical Center Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277375
replace __ftol MSVC6
Hi,
Compiling the following code in MSVC6 gives the linker error 'unresolved
external symbol __ftol'..
// -- Code begin --
#pragma comment(linker, "/entry:Main")
#pragma comment(linker, "/nodefaultlib")
#pragma comment(linker, "/opt:nowin98")
long ftol(double const f)
{ int n;
__asm fld f
__asm fistp n
if(f - n < 0) n--;
return n;
}
extern "C" int const _fltused = 1;
int __stdcall Main(void)
{ double x = 1.0f;
return (int)x; // This line causes the linker error
}
// -- Code end --
..I was wondering if it is possible to make my ftol be the one used
automatically by MSVC6 (so I don't have to do { return ftol(x); } ). The
closest I've come to getting this to work is by adding the following after
the { extern "C" .. _fltused = 1 } line, which stops the linker complaining,
but still doesn't work as the program crashes..
extern "C" long (*_ftol)(double const) = ftol;
..
Thank you for any help,
Kind regards,
Eliott Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277370
LoadLibrary call hangs ..sometime
Hi
i have socket (server) applicaiton which after accept() call forks itself
for every incoming connection and each child process loads the dll's using
loadlibrary function while initializing.
These dlls are actually calling functions from Third part dll's.
Now sometimes during high traffic enviornment i.e. concurrent socket
connections ..some child processes could not load one of my dll and it just
hangs..I have confirm by adding logs before and after the line LoadLibrary
This is very sporadic..
Can anyone explain me what could be the possible cause for this.
My dlll's are compiled with "Use MFC in a Shared DLL" Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277362
VC2005 cannot build project, complains about missing items...
I am trying to compile a code example from a hardware protection key
supplier.
The example should compile but does not on my VS2005 installation.
I suspect that I have not done something I need to do inside the
VS2005 IDE, but being a complete novice in C++ and Visual Studio 2005
I don't know what it can be....
The first problem was that it stopped on this include line:
#include <istream.h>
saying the file could not be found.
After looking in the VC/include dir below VS2005 I found a file called
istream (no extension), which seemed to be a header file so I renamed
it to istream.h.
Next I received no less than 10 errors (lines wrapped due to
newsreader):
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(72) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(73) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(76) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(77) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(84) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(91) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(100) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(108) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(116) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
1>c:\engineering\projects\bosse\safenet\spquery\dsdll.h(124) : error
C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
If I doubleclick the first error I get to this piece of code:
extern __declspec(dllexport) WINAPI SAFEInitGlobal(unsigned char*);
typedef (WINAPI *TSafeInitGlobalFnPtr)(unsigned char*);
extern __declspec(dllexport) WINAPI DecodeKeyID(
unsigned char*,
char*,
RESULTREC*,
unsigned short*);
typedef (WINAPI *TDecodeKeyIDFnPtr)(unsigned
char*,char*,RESULTREC*,unsigned short*);
extern __declspec(dllexport) WINAPI GenerateUpdateStr(
unsigned char *GlobPtr,
SAFECOMMANDREC *safe_commands,
short count,
char *updateStr,
PROD_LIST *prod_list_ptr,
BOOL ScrambleOrder);
As far as I can see there are no unspecified types anywhere here, so
what is the problem????
Now I am at road's end, I have not a single clue as to why the errors
happen. Apparently this compiles fine in an earlier version of VS
(when I load the project it says it has to convert to the new format
and I cannot go back to the old environment afterwards).
Any help appreciated!
(Bear in mind that I am not used to working with VS2005, I have only
worked with VB6 (a lot) and Borland products....
/Bo
Bo Berglund
bo.berglund(at)nospam.telia.com Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277361
CInternetSession
Hello!
For two days now, Iam strugling with some dificulties using
CInternetSession.OpenURL() function. Iam writing simple code for separate
thread function such as:
while(true)
{
CInternetSession csiSession;
CStdioFile* MyFile = csiSession.OpenURL(_T("http://www.someurl.com"));
// working on retrieved data
MyFile->Close();
delete MyFile;
}
Iam using VC2k5 and while building solution Ive received warning:
First-chance exception at 0x7c90eb74 in Project1.exe: 0xC0000008: An
invalid handle was specified.
Warning is poiting to "OpenURL", but I don't have any clue what cause it.
Also Ive changed compiler to VC6 and tried same code again, and came with
similar "Invalid handle" message.
The VC2k5 Allows to click "Ignore" and proceed with app. Ive observed that
app is running "normal" except memory leak at "OpenURL" method.
Ive already searched web for solution but came out (almost) empty.
Could someone help me with this issue? TIA.
--
SOCAR Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277358
a strange question about URLDownloadToFile() and IE
hey all,
i face a strange question about URLDownloadToFile() api function,
the funtion always fail to download an URL, but the URL can be opend
well in IE, what's more, the function can works well to download the
URL after i open the URL on IE, it's really puzzle me.
it should be not a question about source code, maybe thing wrong with
IE?
anybody can help me? thanks.
regards,
jyan Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277351
can vc++2005 make a dll file that not relay on msvcr80.dll?
i hv a dll project which contains only some pure c funcitons, the
project goes well in MSVC6, but when i complie it with vc++2005, the
output window told me: can not find libc.lib,
according to articles on internet, i know that single thread CRT
(libc.lib) will not support any longer, so i ignore the libc.lib in
the dll project seting, then i got errors like:
libcmt.lib(tidtable.obj) : error LNK2005: __encoded_null already
defined in MSVCRT.lib(MSVCR80.dll)
so, it seems that libcmt.lib conflict with msvcrt.lib, so there are
must one i nedd to ignore, the project complie well when i ignore
libcmt.lib, but that's not i want: the dll file depend on msvcr90.dll.
so i try ignore msvcrt.lib, i got erros like this:
error LNK2001: unresolved external symbol __imp__printf
wow, it seems no CRT anymore, no msvcrt.lib then no libcmt.lib?
what should i do to build a msvcr80-depend-free dll file with vc+
+2005?
possible? Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277346
xml with vc++
Hi all,
I am new to xml.
I am developing vc++ application. Here, I am using one text file
for storing data. I am searching from this text file based on search key.
This is sequential search.
Data is like this:
Data.txt
--------
root\Level1\Level2\xyz1
root\xyz2
root1\Level1\xyz3
root1\Level1\Level2\xyz4
root\Level1\xyz5
If user wants "root\Level1", I am searching all (5) records, then I am
returing 1,5 records. In the average and worst case, this is not optimal.
In my application, NoOfRecords may be more than 2,00,000 records.
If I implemented this in tree stucture format in MSXML, Will it imporve
the performance? (i mean, searching from xml document)
Any other alternatives are there?
Please suggest me.
--
Thanks & Regards,
John. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277345
Play/Record compressed/uncompressed WAV,advice needed
Hello,
I am going to start a project that requires recording and playing wav
files (I don't know exactly the format yet).
I know 4 solutions,but I am esitating on which one I am going to use :
- Using MCI
- Using DirectShow
- Using DirectSound
- Using Waveform Functions
Any advice?
Regards.
Nassim. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277333
Play/Record compressed/uncompressed WAV,advice needed
Hello,
I am going to start a project which one of the parts consists on
recording and playing wav files (I don't know exactly the format
yet),I know 4 solutions (if you know more,please tell me) ,but I am
esitating on which is the best and the more reliable :
- Using MCI
- Using DirectShow
- Using DirectSound
- Using Waveform Functions
Any advice?
Regards.
Nassim. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277332
Not enough storage is available to process this command?
Hello,
I have a legacy app at work that is failing intermittently in a call to
CreateCompatibleBitmap:
HDC hdc = GetDC(0);
HBITMAP hbm = CreateCompatibleBitmap( hdc, w, h );
// w * h = 13,591,552
GetLastError() returned 8.
Error message: Not enough storage is available to process this command.
I have 123 GB free on my HDD and I'm running XP with 2 GB of RAM, with over
1 GB available at failure.
The app has approx. 280 GDI objects and 70 USER objects for each instance.
The limit for GDI objects is 10,000 per process. 280 doesn't seem like a
lot; two instances of Internet Explorer have 932 user and 1600 GDI objects
between them. Total for all GDI objects in the system during an app failure
was about 4600.
Can anyone shed some light on this error?
Thank you.
Jim Brown Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277329
name mangling
I was just wondering what the easiest way to figure out how a function
gets name mangled in VC++ is.
I have this function:
class Test
{
int operator[](unsigned int index);
};
I'm trying to figure out how this gets mangled in VC++ 6.0 and VS
2005.
Any help is appreciated.
Thank you. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277328
Difference between .DLL And .LIB
Hi
what is the difference between .DLL And .LIB.
Please clearify this in bit detail.
Thanks
Bye Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277322
Get ASCII value for character when higher than 127
Hello,
For work, I need to write a password filter. The problem is that my C+
+ experience is only some practice in school, 10 years ago. I now
develop in C# which is completely different to me.
But, the password filter needs to be built, so I'm doing my best.
First of all, I am creating an xml string that contains both username
and password, and then I want to write the ascii values for all
characters to a textfile. By using the ascii values I am sure I can
store special characters, also in a textfile.
I got it working, but only when the password only contains characters
that have an ASCII value lower than 127. But, in windows it is
possible to change a password also to something that contains special
characters, like =C3=A9, =C3=AB, or =E2=82=AC.so I also need to be able to =
get these
characters in my filter.
Below is the code that works for characters with ASCII values lower
than 127. Can anyone tell me what I need to do to get this working for
all characters?
I've been searching and puzzling for two days now and haven't gotten
any closer to how to solve this.
Any help will be appreciated.
Thanks in advance,
Sandra
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
#include <windows.h>
#include <ntsecapi.h>
#include <time.h>
#include <fstream>
#include <iostream>
#include "PwdHookNew.h"
#include <sstream>
#include <string>
using namespace std;
#ifndef STATUS_SUCCESS
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
#endif
string GetASCIIString(string oristring)
{
unsigned char ch;
int i, j, k;
string numstrings;
ostringstream oss;
for(i=3D0;i<oristring.size();i++)
{
ch=3Doristring[i];
k =3D int(ch);
if (k<10)
{
oss << "000" << k << "-";
}
else if (k<100)
{
oss << "00" << k << "-";
}
else if(k<1000)
{
oss << "0" << k << "-";
}
else
{
oss << k << "-";
}
}
numstrings=3Doss.str();
oss.clear();
return numstrings;
}
NTSTATUS
NTAPI
PasswordChangeNotify(
PUNICODE_STRING UserName,
ULONG RelativeId,
PUNICODE_STRING Password
)
{
const char* timeStringFormat =3D "%Y-%m-%d_%H-%M-%S";
const int timeStringLength =3D 20;
char timeString[timeStringLength];
// get current date and time
time_t t =3D time(0);
tm *curTime =3D localtime(&t);
strftime(timeString, timeStringLength, timeStringFormat,
curTime);
char path[80];
strcpy (path,"C:\\pwds\\");
strcat (path,timeString);
strcat (path,".txt");
char *usernameStr, *passwordStr;
usernameStr =3D (char*)calloc(1, (UserName->Length/2)+1);
passwordStr =3D (char*)calloc(1, (Password->Length/2)+1);
wcstombs(usernameStr, UserName->Buffer, (UserName->Length/2));
wcstombs(passwordStr, Password->Buffer, (Password->Length/2));
char xmlmsg[150];
strcpy (xmlmsg,"<userpwd><username>");
strcat (xmlmsg,usernameStr);
strcat (xmlmsg,"</username><password>");
strcat (xmlmsg,passwordStr);
strcat (xmlmsg,"</password></userpwd>");
string xmlASCII =3D GetASCIIString(xmlmsg);
ofstream outPwd(path, ios::app);
if (!outPwd)
{
ofstream outPwd(path, ios::out );
}
outPwd << xmlASCII ;
outPwd.close();
return STATUS_SUCCESS;
} Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277314
Build Switching
Hi there,
I have a VC application that I want to implement a switch for which will
change the name of the application, as well as several other resource items.
I implemented a pre-compile check within the .rc file for the version
information, but VC removes my check and replaces it for the section that
evaluated to true, for example...
#define APP2
#ifdef APP2
//version info block here for app 2
//the entire block gets replaced by the code within this section.
#else
//version info block here for app 1
#endif
So my question is, how do I specify to use a different set of resources
for a specific compile switch?
Many thanks in advance.
Nick. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277299
how to run any user exe when computer start in
hi guys, can u please tell me how we can start any exe when my
computer start. actualy i have an exe that i want to start at the time
of startup window. thanks Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277298
how to write a binary file
I am trying to create a file of bytes from my character array
char* chars with length int count.
I wrote the code:
FileStream file = new FileStream(S"chars.dat", FileMode::Create,
FileAccess::Write);
BinaryWriter binary = new BinaryWriter(file);
binary.write(chars, count);
binary.close();
My compiler doesn't recognize FileStream and BinaryWriter.
I tried:
using namespace System::IO;
but it doesn't recognize that either?
Is my code correct, and what "using" or "include" do I need?
By the way, in new FileStream(S"chars.dat", ...), what does the "S" mean?
Thanks for reading this. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277292
Re: delete vs delete[]
The error checking available in VC is pretty good but the one item I
miss dearly is a way to validate printf() style calls. These are often
hard to test routinely as many calls are for very exceptional error
conditions that are difficult, if not impossible to create in boundary
testing. The issue is compounded by that these calls are are often
copy/pasted from similar error messages meaning we can miss something
"minor" in the edit that ends up tragic should the exception ever be
true.
if (1 == 2) printf ("Woops! 2 is %s, expected %u", 1, 2);
That should generate an error and perhaps two warnings. The error is
the %s and int type mis-match and the warnings are a %u vs int type
mis-match and that the trailing \n is missing though at the moment I
can't think of a nice clean way to flag that it's ok the string does
not have a \n.
Marc Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277290
Re: delete vs delete[]
The error checking available in VC is pretty good but the one item I
miss dearly is a way to validate printf() style calls. These are often
hard to test routinely as many calls are for very exceptional error
conditions that are difficult, if not impossible to create in boundary
testing. The issue is compounded by that these calls are are often
copy/pasted from similar error messages meaning we can miss something
"minor" in the edit that ends up tragic should the exception ever be
true.
if (1 == 2) printf ("Woops! 2 is %s, expected %u", 1, 2);
That should generate an error and perhaps two warnings. The error is
the %s and int type mis-match and the warnings are a %u vs int type
mis-match and that the trailing \n is missing though at the moment I
can't think of a nice clean way to flag that it's ok the string does
not have a \n.
Marc Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277289
Re: vc++ 2005 express support making dll?
On May 23, 10:17 pm, "Alex Blekhman" <x...@oohay.moc> wrote:
> "jyan" wrote:
> > hey all,
> > recently, i download free vc++ express edition, it works
> > well, and
> > what's more it's free to use.
> > but i find that this version seems does not support making
> > dll file? i
> > like to create a project which will simply output
> > functions in a dll
> > file, but the radio button for dll is disabled in
> > "application type"
> > of application wizard.
> > is that still possible to create a dll project with vc++
> > express
> > edition?
>
> Yes, here's description of how to unlock DLL application
> type:
>
> "Using Visual C++ 2005 Express Edition with the Microsoft
> Platform SDK"http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
>
> Alex
thanks a lot, Alex, i will read the article, which seems belong to MS
pages, it's strange why dont they just make the dll application type
available on UI? Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277285
Re: vc++ 2005 express support making dll?
On May 23, 10:17 pm, "Alex Blekhman" <x...@oohay.moc> wrote:
> "jyan" wrote:
> > hey all,
> > recently, i download free vc++ express edition, it works
> > well, and
> > what's more it's free to use.
> > but i find that this version seems does not support making
> > dll file? i
> > like to create a project which will simply output
> > functions in a dll
> > file, but the radio button for dll is disabled in
> > "application type"
> > of application wizard.
> > is that still possible to create a dll project with vc++
> > express
> > edition?
>
> Yes, here's description of how to unlock DLL application
> type:
>
> "Using Visual C++ 2005 Express Edition with the Microsoft
> Platform SDK"http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
>
> Alex
thanks a lot, Alex, i will read the article, which seems belong to MS
pages, it's strange why dont they just make the dll application type
available on UI? Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277284
C macro for ellipsis(...)
Hi I'd like to write a macro for the function with a variable argument, for
example
#define PrivateLog(szFormat,...) PublicLogWrite(_TODAY_,szFormat,...)
// where _TODAY_ is a static string containing e.g. "May 23, 2007"
void PublicLogWrite( char *szToday, char *szFmt, ... )
{
va_list arglist;
va_start( arglist, szFmt );
// ... e.g. vsprintf()
va_end( arglist );
// ... e.g. fprintf()
}
so the caller should look like,
PrivateLog( "Error:%s ReturnCode=%d", szErrorMessage, nError );
PrivateLog( "Info:%s Len=%d #Lines=%d", szInfoMessage, nLen, nNumLines );
But those 2 lines generates the compilation errors:
error C2059: syntax error : '...'
Anyone knows how to resolve this?
TIA. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277273
vc++ 2005 express support making dll?
hey all,
recently, i download free vc++ express edition, it works well, and
what's more it's free to use.
but i find that this version seems does not support making dll file? i
like to create a project which will simply output functions in a dll
file, but the radio button for dll is disabled in "application type"
of application wizard.
is that still possible to create a dll project with vc++ express
edition?
p.s. i try to find anwser with google, but the most related page is
in japanese language, which looks like a puzzle to me :(
thanks a lot.
regards,
jyan Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277271
events?
Hi
I ahve witten down client/Server application in visual C++ 6.o
I have used Single document and added Dialogues to it.
Now i have to write report.
My co-ordinator is sayng that i also have to write about events.
I am confused what he means by events.
Does anyone have some idea.
Thanks
Bye Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277266
Re: Can someone explain how these operator is suppose to work
On May 23, 12:56 am, Anders Eriksson <andi...@gmail.com> wrote:
> I'm using a 3:rd party library and in one class I have a protected variable
> that I need to get.
>... The class looks like this
> xObject& operator*(){ return *m_pObject;}
> xObject* operator->(){ return m_pObject;}
>...
> If I have an instance of CYObject called myObject how do I get the
> myObject->m_pObject??
The first declaration is saying that if the * operator is used on a
CYObject then return a reference to an xObject.
The second declaration is saying that if the -> operator is used on a
CYObject then to return a pointer to an xObject.
Let's assume xObject has a public int called nValue.
For the first operator (*) you can use
xObject & myxObject = *myCYObject;
int myValue1 = myxObject.nValue;
and for the second operator (->) it's
int myValue2 = myCYObject->nValue;
> English is not my first, or second, language
> so anything strange, or insulting, is due to
> the translation.
> Please correct me so I may improve my English!
Your English is good.
Marc Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277264
Can someone explain how these operator is suppose to work
Hello,
I'm using a 3:rd party library and in one class I have a protected variable
that I need to get.
I see that the creator of the class has two operators that seem to be the
trick to get the value but I don't get how to use the operators.
The class looks like this
Class CYObject
{
protected:
xObject* m_pObject;
// a number of other variables...
public:
xObject& operator*(){ return *m_pObject;}
xObject* operator->(){ return m_pObject;}
}
If I have an instance of CYObject called myObject how do I get the
myObject->m_pObject??
// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English! Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277262
Faster to assign null pointer....
Is it faster to check for NULL function pointers or to assign a dummy
function that does nothing?
if(fp != NULL)
fp->somefunction(); //some function does something
or just assign dummy function that does nothing
fp->somefunction(); //does nothing. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277255
Warning C4996
How can I get rid of the following warning C4996 (only using checked_copy
doesn't solve the problem):
warning C4996: 'std::copy': Function call with parameters that may be unsafe
- this call relies on the caller to check that the passed values are correct.
To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on
how to use Visual C++ 'Checked Iterators' Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277254
How to save data to Access database file!
Hi All,
Good afternoon,
I am working on winamp general purpose pluggin "gen_whatsplaying " project
downloaded from the site www.schaffrath.net
I compiled and build the project successfully using platform SDK Feb 2003
and Speech SDK5.1.
Now the winamp plugins "gen_whatsplaying" interface saving
the data related to songs currently being played by Winamp to a specified
text file.
such as time the song starts playing, name of the song currently being
played etc.
depending on the parameters specified in the pluggin's template file.
Now, I want to save the data directly to a MSAccess database file, which is
currently being saved in a text file, such as time the song starts playing,
name of the song currently being played etc.depending on the parameters
specified in the pluggin's template file. e.g. "6:23:39 PM- D:\shaan\03 WOH
PEHLI BAAR.mp3" this information I want to store in two different field of
Access database table.
please let me know how do I do that? Do I need to use ADO and other library
to get the connectivity with MSAccess db first? Let me know if you have any
idea about it.
I really appreciate yours help and kind cooperation with me.
Thanks,
shyam Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277236
Implicitly loaded dll question
Hi,
I am using a dll in my program which is loaded implicitly (using .h
and .lib files). This is working fine. But in this case i don't have
privilege to load this dll only if certain criteria is met. I don't
want to change the already written code to explicit linking. Is there
anyway that i load the dll only if certain flag is set ?
Thanks
Ashok Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277232
general exception
If you catch a general exception with catch(...), is there an easy way
to figure out what type
of exception you caught?
Thank you. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277222
write to file with no used of buffered-IO functions
Hello,
How can I write to file 100,000 blank characters, not by using fwrite,
so I shall not use a buffered-IO ?
I want to write 100,000 bytes, with one signal I/O command
(and not using a buffer with 100,000 size long).
Thanks :) Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277212
C++ quirks - frustrated with secure CRT [long]
Hi everyone,
I've been researching and asking this question around quite a lot
today without a satisfactory answer. I have difficulties interpreting
the documentation for the secure version of some CRT methods and I
would like to know some opinions if you would care to share.
As a rule, it seems that most of them take an extra parameter of type
size_t which is usually called sizeofbuffer which - despite the name
hint that a C\C++ programmer would take it as indication that the byte
size is what needed to be passed - actually requires the number of
elements in the array to be passed and , considering wide char
versions as well as TCHAR versions the documentation insists that one
passes _countof instead of _sizeof where that parameter is required:
TCHAR buffer[512];
_secure_method_s(buf, _countof(buffer),...);//good!!
_secure_method_s(buf, _sizeof(buffer),...);//bad!!
as exemplified by _tcscpy_s sample from MSDN:
errno_t _tcscpy_s(
TCHAR *strDestination,
size_t numberOfElements,
const TCHAR *strSource
);
strDestination
Location of destination string buffer
numberOfElements
Size of the destination string buffer.//jabba : oh well let's not
be explicit here
strSource
Null-terminated source string buffer.
MS sample:
char string[80];
// of course we can supply the size explicitly if we want to:
strcpy_s( string, _countof(string), " strcpy _s!" ); //note usage
of _countof
But witness definition of _vsntprintf_s
int _vsntprintf_s(
TCHAR *buffer,
size_t sizeOfBuffer,
size_t count,
const TCHAR*format,
va_list argptr
);
Parameters
buffer
Storage location for output.
sizeOfBuffer
The size of the buffer for output./*note jabba : size expressed as
WHAT?????Can't you give me more info than what is already comprised in
the name of the parameter????*/
count
Maximum number of characters to write (not including the
terminating null), or _TRUNCATE.
format
Format specification.
argptr
Pointer to list of arguments.
It would seem (by hints of the naming used for parameters, not through
explicit parameter documentation )that sizeOfBuffer refers to the
actual size in bytes of the buffer so a good call would be
int nSize = 0;
TCHAR buff[10];
memset(buff, 0, sizeof(buff));
va_list args;
va_start(args, formatstring);
nSize = vsntprintf_s( buff, sizeof(buff), _TRUNCATE, formatstring,
args);
MS being the nice guys that they are only provide a regular char
sample:
int nSize = 0;
char buff[10];
memset(buff, 0, sizeof(buff));
va_list args;
va_start(args, formatstring);
nSize = vsnprintf_s( buff, sizeof(buff), _TRUNCATE, formatstring,
args);//hello what am I supposed to infer??? That is byte size of
course!!!
Ha! But look what the vswprint.c (CRT source code) definition looks
like:
int __cdecl _vsnwprintf_s (
wchar_t *string,
size_t sizeInWords,<-----exactly the opposite hint!
size_t count,
const wchar_t *format,
va_list ap
)
So it looks like they expect you to pass the count of elements in the
array instead of its byte size.
I can produce this kind of open to interpretation MSDN documentation
for a lot of other secure CRT methods.
Anyone has any experience with this that can confirm whether all of
the secure methods require consistently the buffer's byte size or all
of them require the element count or does it really vary from method
to method and what's the definitive hint on which one to pass?
Thanks,
Jabba Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277205
How to keep a Dialog's width and height in a solid ratio
Inv: WindowsXP, VC++6.00
I made a sub dialog window with alterable size. Now I need the width and
height kept a solid ratio while changing. I tried as follows,
in void CDlg1::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
cy = cx * 3 / 4 ;
SetWindowPos( &wndTop, 0, 0, cx, cy,
SWP_NOZORDER|SWP_NOMOVE|SWP_SHOWWINDOW );
}
But it doesn't work. Please help.
William Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277198
namespace trouble
Hi,
one of the "typedefs" of .NET 2002 Platform SDK has a namespace conflict
with my third party library.
Changing either of them would cause compilation failure. What can I do in
this situation?
1)
typedef
enum
{
FUNC_STATIC
....
};
2)
#define FUNC_STATIC 0x0000001L
Any hints?
Thanks in advance Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277188
LINK : fatal error LNK1104: cannot open file "nafxcwd.lib"
Hi all,
I'm a C newbie in a desperate need of help. My background isn't
programming but engineering, so my programming skills are somewhat
limited (I am able to write simple single-threaded progs in C, but
hardly more than that). It just happened that my work requires me to
take a program and strip it off all kind of GUI, make it just a simple
command prompt thingie. And so I did, more or the less. Now, I didn't
remove any includes or anything of a kind, but my stripped proggie
consistently refuses to link (compiling is OK) and the error I get ts
the one in the subject. I searched all of my hard drive, this file
doesn't exist on it.
But the original program never "jumped" on it, as if it never required
it in a first place.
As I said I never added anything to the program, only removed some of
the GUI related code... And the new program seems to require something
that the old one never did...
I'm open to any suggestions, as due to my limited programming skills I
just don;t know where to look for the problem's root.
Thanks! Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277186
W.Forms
Hi every body.
The code written down (by C++/ CLR console).
How can I compile it by Windows Form.
Can any persn wants to help??
Thanks
Beginner
+++++++++++++++++++++++++++++++++++++++++++++
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
int magic;
int guess;
Console::Write(L"Enter Your Guess Number : ");
guess=Convert::ToInt32(Console::ReadLine());
if(guess==7)
{
Console::WriteLine(L" Bravo it's Magic Number");
}
else
{
Console::WriteLine(L" Sorry Not Magic Number");
}
return 0;
} Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277185
delete vs delete[]
I was just wondering why the compiler won't warn you when you try to
do this:
TCHAR *t = new TCHAR[20];
delete t;
Also, how exactly does the behavior of that differ from the correct
way:
TCHAR *t = new TCHAR[20];
delete[] t;
Thank you. Tag: http://www.real-article.com/addurl/addurl.htm Tag: 277178