Dependency generation (CL /E)
Currently with VC6, we invoke the CL compiler with /E, in order to parse the
list of included files, and thus reconstitute our dependency lists.
But with VC7, the compiler introduces absolute paths into the spew (same if
you use /showIncludes). We filter these out, considering the probably
originate from the system path (and we aren't interested in tracking these
dependencies).
* Why does CL do this now? Why has this behavior changed?
* Is it a bug?
* Is there a work-around (regardless of the answers to the other questions)?
Thank you,
Dan Tag: CListBox item's color Tag: 251720
findFirstFile, findNextFike
I need codes to access all files in all subdirectory in one directory in
VC++/VStudio but in console (DOS) mode. Thank you for your help in advance.
M.K. Tag: CListBox item's color Tag: 251718
Setting Title bar size programatically ?
Is it possible to set the height of a title bar on a window programatically ?
Does anyone know how ?
Thanks,
Ray Tag: CListBox item's color Tag: 251709
Fatal error LNK1104: cannot open file "nafxcwd.lib"
I am trying to build an open source VC++ 6 project using VC++ 6 Standard but
I am getting the following error message:
Linking...
LINK : fatal error LNK1104: cannot open file "nafxcwd.lib"
Error executing link.exe.
LeechBlocker.dll - 1 error(s), 1 warning(s)
After searching my drive for nafxcwd.lib, the file was not found and it
appears that this file is not included in the VC++ 6 Std. installation.
Disabling debug gives the same message above indicating a different file
named "nafxcw.lib".
For my project settings, I am using 'Use MFC in a Shared DLL' (all
configurations).
Any comments or suggestions are appreciated. Thank you. Tag: CListBox item's color Tag: 251707
Error calling the function HrESERestoreComplete
Hello All,
I am writing an application to backup and restore M.S. Exchange server
programatically. I am using the Exchange Backup and
Restore API and am developing the application in VC++ 6.0 on a Windows
Server 2003 Enterprise Edition. I am able to do the
backup successfully but I am getting error in the function
"HrESERestoreComplete" during the resore. I am trying to call the
function HrESERestoreComplete as follows:
//<step 8>
//HrESERestoreComplete
CString strTempLocationPath;
CString strTempLocationPath1;
strTempLocationPath = _T("C:\\viraj\\exchangedata_bkp\\temp");
strTempLocationPath1 = _T("C:\\viraj\\exchangedata_bkp\\temp");
WCHAR * wszMNURestoreInstanceSystemPath =
strTempLocationPath.GetBuffer(strTempLocationPath.GetLength());
WCHAR * wszMNURestoreInstanceLogPath =
strTempLocationPath1.GetBuffer(strTempLocationPath1.GetLength());
unsigned long fMNUFlags = ESE_RESTORE_COMPLETE_ATTACH_DBS;
typedef HRESULT (ESEBACK_API *HrESERestoreComplete) (IN HCCX
hccxRestoreContext, IN WCHAR * wszRestoreInstanceSystemPath,
IN WCHAR * wszRestoreInstanceLogPath, IN WCHAR * wszTargetInstanceName, IN
unsigned long fFlags);
HrESERestoreComplete fnMNURestoreComplete = NULL;
fnMNURestoreComplete = (HrESERestoreComplete) GetProcAddress
(g_hESEDll,"HrESERestoreComplete");
if(fnMNURestoreComplete)
hr = (fnMNURestoreComplete)
(phccxMNURestoreContext,wszMNURestoreInstanceSystemPath,
wszMNURestoreInstanceLogPath,wszSrcInstanceName,fMNUFlags);
if(hr != S_OK)
{
LPVOID lpMsgBuf;
DWORD dw = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,0,NULL);
CString strMessage = _T("");
strMessage.Format(_T("failed with error %d : %s"),dw,lpMsgBuf);
AfxMessageBox(strMessage);
LocalFree(lpMsgBuf);
return MNU_EXCHANGE_RESTORE_FAILURE;
}
//</step 8>
All the inputs seem to be correct.
Output:
hr = -939585532
dw = 4294965485
Expected Output:
hr = S_OK
Can anyone please point the mistake in my code or give me sample code for
the "HrESERestoreComplete" Function?
Thanks,
Viraj
a.viraj@mobiliti.com
http://www.mobiliti.com
732-248-8300 ext 234 Tag: CListBox item's color Tag: 251705
Modal dialog behavior
When an application displays a modal dialog box, the application's message
pump is blocked until the dialog box is dismissed. How is it then that if
you move that dialog box around, the parent application is redrawn? Are the
WM_PAINT messages in the parent application's message queue still getting
processed, or is something else going on here?
Thanks,
DC Tag: CListBox item's color Tag: 251702
initializing private static array
Hi gang! This is more of a preference issue than a syntax or C++ standards
question. I have a class that has a private static array as a data member.
I know that in the source file for the class, one would normally initialize
all the static data members prior to any operation definitions. However,
with arrays, the compiler thinks that you are redefining the length of the
static array (when specifying a specific index). I can solve this by
"modifying" (as opposed to initializing) the array inside the class
constructor. I know this isn't usually considered "good practice" since
instantiation of each object of the class will execute useless code (the 1st
object will actually modify the data member, all other instantiations will
simply reset the values to what's already stored).
What's the best way to initialize static arrays? Oh, and I understand that
the array will already be initialized to all zero's, but I'd like to
initialize it to something else (it's actually a private static const array).
Thanks as always! Tag: CListBox item's color Tag: 251692
Trade-offs when floating poing consistency?
What are the trade-offs when I disable floating point consisetncy?
I guess my program is still C++ compliant, isn't it?
--
Angel Tsankov
fn42551@fmi.uni-sofia.bg Tag: CListBox item's color Tag: 251688
Is it necessary to have default constructor of a class ??
Hi,
I want to ask a question whether it is a must to have default
constructors (without any parameter) of a class or it will be ok without it
also... I have tried, without default constructor, it is working fine.. but
i heard somewhere that it should be there.. Please tell me what is correct
??
--jigar Tag: CListBox item's color Tag: 251687
enum problem
A class like this:
class Sample
{
public:
enmu{
iFirst,
iSecond
}
}
I wanna know how does the machine allocate the memory for the variable in
enum type. Does it like a static member variable in class ?
Thanks a lot. Tag: CListBox item's color Tag: 251679
Error during Exchange Backup
Hello All,
I am writing an application to backup and restore M.S. Exchange server
programatically. I am using the Exchange Backup and Restore API and am
developing the application in VC++ 6.0 on a Windows Server 2003 Enterprise
Editioon. I am able to do the backup successfully but I am getting error in
the function "HrESERestoreAddDatabase" during the resore. I am trying to call
the function HrESERestoreComplete as follows:
//<step 8>
//HrESERestoreComplete
CString strTempLocationPath;
CString strTempLocationPath1;
strTempLocationPath = _T("C:\\viraj\\exchangedata_bkp\\temp");
strTempLocationPath1 = _T("C:\\viraj\\exchangedata_bkp\\temp");
WCHAR * wszMNURestoreInstanceSystemPath =
strTempLocationPath.GetBuffer(strTempLocationPath.GetLength());
WCHAR * wszMNURestoreInstanceLogPath =
strTempLocationPath1.GetBuffer(strTempLocationPath1.GetLength());
unsigned long fMNUFlags = ESE_RESTORE_COMPLETE_ATTACH_DBS;
typedef HRESULT (ESEBACK_API *HrESERestoreComplete) (IN HCCX
hccxRestoreContext, IN WCHAR * wszRestoreInstanceSystemPath,
IN WCHAR * wszRestoreInstanceLogPath, IN WCHAR * wszTargetInstanceName, IN
unsigned long fFlags);
HrESERestoreComplete fnMNURestoreComplete = NULL;
fnMNURestoreComplete = (HrESERestoreComplete) GetProcAddress
(g_hESEDll,"HrESERestoreComplete");
if(fnMNURestoreComplete)
hr = (fnMNURestoreComplete)
(phccxMNURestoreContext,wszMNURestoreInstanceSystemPath, wszMNURestoreInstanceLogPath,wszSrcInstanceName,fMNUFlags);
if(hr != S_OK)
{
LPVOID lpMsgBuf;
DWORD dw = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,0,NULL);
CString strMessage = _T("");
strMessage.Format(_T("failed with error %d : %s"),dw,lpMsgBuf);
AfxMessageBox(strMessage);
LocalFree(lpMsgBuf);
return MNU_EXCHANGE_RESTORE_FAILURE;
}
//</step 8>
All the inputs seem to be correct.
Output:
hr = -939585532
dw = 4294965485
Expected Output:
hr = S_OK
Can anyone please point the mistake in my code or give me sample code for
the "HrESERestoreComplete" Function?
Thanks,
Viraj
a.viraj@mobiliti.com
http://www.mobiliti.com
732-248-8300 ext 234 Tag: CListBox item's color Tag: 251673
Component Categories
The discussion of Component Categories in the version of MSDN that is
included with Visual Studio .NET 2003 includes the following statement:
> This is not a definitive list of categories; further categories are likely
> to be defined in the
> future as new requirements are identified. An up-to-date list of component
> categories is
> available from Microsoft on their world wide web site, this list reflects
> those component
> categories that have been identified by Microsoft and any others that
> about which vendors
> have informed Microsoft.
Is this true? I can not find a definitive list of component categories on
miscrosoft.com. Is there one? Where?
Thanks.
David Liebtag Tag: CListBox item's color Tag: 251665
Ensuring one instance of an app
Hello all,
What is the easiest way to ensure that only one instance of my app may be
running at a time? If the user attempts to start a second instance, the
first instance should be restored.
Thanks,
Dave Tag: CListBox item's color Tag: 251664
start unix process from c++ win32 app
I am trying to write a win32 app that will start mulitple instances of an exe
on UNIX. The exe is located on the backend UNIX node and takes several
arguments. I'm wanting to build a frontend win32 app where the user can
input the needed arguments and then kick off the exe on the backend UNIX
machine without having to log into the UNIX box.
My question is how do I start the process on UNIX. Is there simply a
function that I can pass the location of the exe and all the arguments? Tag: CListBox item's color Tag: 251657
swprintf() bug in vc7?
I'm using VS .Net 2003 with a c++ project compiled with unicode support.
I have a project that is calling swprintf(). At runtime I'm seeing an
exception from one of the low level calls. Looking at the callstack I see
that my code is calling this code in vc7/crt/src/swprintn.cpp:
int __cdecl swprintf (
unsigned short *string,
size_t count,
const unsigned short *format,
...
)
{
return swprintf(reinterpret_cast<wchar_t *>(string), count,
reinterpret_cast<const wchar_t *>(format));
}
And this code is calling the actual swprintf() function.
This intermediate swprintf function is completely ignoring the arguments
passed in and the call to the actual swprintf() gets the wrong parameters
because of it. I've tried casting things to get the compiler to call the
real swprintf() function but this hasn't seemed to work around this odd
function call.
How is this call ever expected to work correctly? Is this a known bug that
has been fixed? I've seen no mention of it in the msdn forums or in the
knowledge base or in searches on google. Tag: CListBox item's color Tag: 251653
vc6->vc7 template class no longer compiles error C2511
Hi,
Moving from VC6 to VC7, a templated class I wrote 5 years ago has stopped
compiling with the C2511 error (No version of the funtion is declared with
the specified parameters.
class defn starts with
** begin .h ***
class CMBCComGateway;
struct R;
template <class R> class CMBCComTransaction
{
// Construction
public:
CMBCComTransaction(CMBCComGateway *pGateway, CMBCComPacket *pPacket)
{
m_pGateway = pGateway;
m_pPacketIn = pPacket;
};
~CMBCComTransaction() {};
// Implemenation
public:
// Request and Report Transaction Methods
BOOL Execute(R *pASDU);
.
.
.
** end .h ***
The function in question is the execute funtion which is then defined in a
.cpp file somthing as follows:
** begin .cpp ***
// Report class implementation
BOOL CMBCComTransaction<TRANS_REPORT_SYSTEM_STATUS>::Execute(R *pASDU)
{
TRANS_REPORT_SYSTEM_STATUS
*pTrans = pASDU;
// Re-set the reported status flag to eliminate alarms during this re-sync
m_pGateway->m_bReportedStatus = FALSE;
.
.
.
** end .cpp ***
Any clues? Not sure what changed here.
Thanks,
Bob Tag: CListBox item's color Tag: 251650
COleMessageFilter::Register always returns FALSE
I'm trying to create a situation such that a CArchive::ReadString can timeout.
I derived a new class from both CArchive and COleMessageFilter. In that
derived class I added an OnMessagePending method and also set up a timer so
that it "triggers" after a set number of seconds, and should therefore invoke
the OnMessagePending method. That OnMessagePending method does not get
called, however, unless the Filter is "registered". So, after creating an
instance of my derived class I call its Register method (actually, the base
class's COleMessageFilter::Register method). But the call to Register always
fails, returning FALSE.
Anyone have a suggestion as to what I'm doing wrong? Tag: CListBox item's color Tag: 251649
Visual Studio NET Enterprise Architect 2002 and Visual Studio NET 2003
very hard is fix exactly group for this question.. but I am sure that some
of people here have some experience with these compilers: Visual Studio NET
Enterprise Architect 2002 and Visual Studio NET 2003
1. What is difference between Visual Studio NET Enterprise Architect 2002
and Visual Studio NET 2003
2. If I try user Visual Studio NET 2003, what I have not included inside (in
compare with Visual Studio NET 2003)?
3. Why Visual Studio NET 2003 is created?
4. Have Microsoft some newer versions of Visual Studio NET? Tag: CListBox item's color Tag: 251648
CMenu from ID
Hi,
Is there any way to get a CMenu object from the ID of the menu? If not,
what is the best way to get a CMenu object of a menu.
Thanks
Marcus de Leon Tag: CListBox item's color Tag: 251639
Function prototypes
Hi,
In my C++ book I am reading an example where they declare a prototype of a
function this way:
void swap(int *x, int *y)
which is OKAY, I understand that this function takes 2 pointers.
Then they go onto another example with a function prototype as follows:
short Factor(int*, int*)
which at my understanding again takes in 2 pointers. However the book does
not go into any explaination on this different wrinkle of the prototype.
Basically,
why would I go with the (int*) as opposed to the (int *x).
If I would explain this to myself, I guess its just two different ways of
declaring the parameters of a function prototype !??! Where one declares it
with variables and the other one doesn't.
All input to this simple question is super appreciated!!!!
--
Best regards
Robert
--
Best regards
Robert Tag: CListBox item's color Tag: 251638
Pointer to member functions and inheritance
Hey, I'm porting a relatively large chunk of code over from VC6 to 2005, I've
run into an odd inheritance issue with class member pointers.
We have an adapter system to generalise access to certain classes that goes
like
template <class T>
class Adapter
{
public:
template <long (T::*p)(int x)>
class DoStuff
{
public:
static long func(int x)
{ return 3; } // Obviously in real life it does a little more
};
};
Given a simple class hierarchy:
class A
{
public:
long X(int a)
{ return 1; }
};
class B : public A
{
public:
long Y(int b)
{ return 2; }
} ;
The following code builds fine on VC6, but fails on 2005
int main(int argc, char* argv[])
{
long (B::*fn1)(int);
long (*fn2)(int);
long (*fn3)(int);
fn1 = &B::X; // OK
fn2 = Adapter<B>::DoStuff<&B::X>::func; // C2440:
// 'specialization' : cannot convert from 'overloaded-function' to 'long
(__thiscall B::* )(int)'
fn3 = Adapter<A>::DoStuff<&B::X>::func; // OK
}
In short, to fix it we had to add an override of X() to B, which called
__super::X(), which is hardly ideal.
Anyone any thoughts on where this fits in?
Thanks,
Brendan. Tag: CListBox item's color Tag: 251630
What is the most elegant way to convert string from unicode to ANSI?
Hi, again.
I set my project UNICODE, and use TCHAR, wstring, and so on.
But, some legacy api need ANSI, so I use WideCharToMultiByte(CP_ACP, ...)
If I want to use it properly, I should call this method twice to know exact
way for char* and
dynamic allocation and Whew...
Do you have any elegant and beautiful way to convert wstring (or
CStringT<wchar_t> or wchar_t) to char ?
Thanks in advance. Tag: CListBox item's color Tag: 251622
Internationalized font
Hi,
Env: Windows2000, VC++6.00
I just made a MFC based application under English version of VC++6.
All characters in the app are in English and it can be run on
DBCS(Double-byte Character Set) environment, such as Japanese, Chinese
Windows.
But I find out the font sizes(height, width, interval and so on) are
different between English OS and DBCS OSs.
The current font I set in my dialog is "MS Sans Serif". From MSDN, I know
that it will be changed into system font on DBCS OSs.
I wonder if there is a font(Dialog's font or CStatic's font ) that can keep
the same sizes in all OSs?
Please help!
William Tag: CListBox item's color Tag: 251618
Weird output ?
Hi there,
I have been trying for 2 hours and I can't understand the output of my
program. If you may please consider the following code fragment:
//==================================================
//==================================================
#include <iostream>
using namespace std;
class SimpleCat
{
public:
SimpleCat();
~SimpleCat();
int GetAge(int Decision);
void SetAge(int age, int Decision);
private:
int itsAge_Val;
int itsAge_Ref;
int itsAge_Pointer;
int itsAge_PHeap;
};
SimpleCat::SimpleCat()
{
cout << "Constructor called. \n";
itsAge_Val = 0;
itsAge_Ref = 0;
itsAge_Pointer = 0;
itsAge_PHeap = 0;
}
SimpleCat::~SimpleCat()
{
cout << "Destructor called \n";
}
void SimpleCat::SetAge(int age,int Decision)
{
switch (Decision)
{
case 1:
itsAge_Val = age;
break;
case 2:
itsAge_Ref = age;
break;
case 3:
itsAge_Pointer = age;
break;
case 4:
itsAge_PHeap = age;
break;
default:
itsAge_Val = 99;
itsAge_Ref = 99;
itsAge_Pointer = 99;
itsAge_PHeap = 99;
break;
}
}
int SimpleCat::GetAge(int Decision)
{
switch (Decision)
{
case 1:
return itsAge_Val;
break;
case 2:
return itsAge_Ref;
break;
case 3:
return itsAge_Pointer;
break;
case 4:
return itsAge_PHeap;
break;
default:
cout << "Default Decision";
break;
}
}
void Function0(SimpleCat theCat); //Passing an object by value
void Function1(SimpleCat & theCat); //Passing by reference
void Function2(SimpleCat *pRags); //Passing a by pointer
void Function3(SimpleCat *pRags); //Pass ptr that points to obj on heap
int main()
{
int a;
SimpleCat Frisky; //Declare for passing
by value
SimpleCat RefFrisky; //Declared for passing by reference
SimpleCat pFrisky; //Declared for passing
by pointer
SimpleCat * pRags = new SimpleCat; //Declared for passing by pointer
that //points to an object on the heap
Function0(Frisky); //Call by value
Function1(RefFrisky); //Call by reference
Function2(&pFrisky); //Call by pointer
Function3(pRags); //Call by pointer that points to heap
cout << Frisky.GetAge(1) << "\n";
cout << RefFrisky.GetAge(2)<< "\n";
cout << pFrisky.GetAge(3)<< "\n";
cout << pRags->GetAge(4)<< "\n";
delete pRags; //Clean up
cin >> a;
}
void Function0(SimpleCat theCat) //Passing by value
{
theCat.SetAge(10,1);
}
void Function1(SimpleCat &theCat) //Passing by reference
{
theCat.SetAge(20,2);
}
void Function2(SimpleCat *pRags) //Passing by pointer
{
pRags->SetAge(30,3);
}
void Function3(SimpleCat *pRags) //Passing by heap pointer
{
pRags->SetAge(40,4);
}
//==================================================
//==================================================
Believe it or not this is the output I get:
Constructor called.
Constructor called.
Constructor called.
Constructor called.
Destructor called
0
20
30
40
Destructor called
Now, didin't the definition of the function: Function0(Frisky); set
itsAge_Val to 10 ?
1) Why is the output showing 0 instead of 10 ?
2) Shouldn't the first destructor be called after 0?
Sorry about the lenghty example, however I had to show it all so there would
be no confusion!
All help appreciated!
--
Best regards
Robert Tag: CListBox item's color Tag: 251614
on file delete
Hi,
In my MFC app I need to receive a message from the system when the user
deletes a file on the hard drive (
with the path and name of the file of course)
I've looked thoughout the WIN API, but the closest message that I found is
ON_WM_DEVICECHANGED
Does such a message exist?
Thanks. Tag: CListBox item's color Tag: 251608
multi line listbox
Hello all
I program win32 api in C and I need a multiline listbox, could anyone please
tell me how I can accomplish that or refer me to some sample application.
Thank you in advance Tag: CListBox item's color Tag: 251606
By Reference or By Pointer?
Hi there!
Between being a VC++ beginer and reading books with typo's in them, makes
the learning curve quite complicated! Anyhow, I would like to clear something
up here!
IN THE BOOK EXAMPLE, it calls the following code fragment:
Listing 12.1 Passing objects by reference
and here is the example as written in the book:
#include <iostream>
using namespace std;
class SimpleCat
{
public:
SimpleCat();
SimpleCat(SimpleCat&);
~SimpleCat();
};
SimpleCat::SimpleCat()
{
cout << "Simple Cat Constructor... \n";
}
SimpleCat::SimpleCat(SimpleCat&)
{
cout << "Simple Cat Copy Constructor... \n";
}
SimpleCat::~SimpleCat()
{
cout << "Simple cat destructor...\n";
}
SimpleCat FunctionOne (SimpleCat theCat);
SimpleCat* FunctionTwo (SimpleCat *theCat);
int main()
{
cout << "Making the Cat....\n";
SimpleCat Frisky;
cout << "Calling Function1,,,\n";
FunctionOne(Frisky);
cout << "Calling Function2,,,\n";
FunctionTwo(&Frisky);
return 0;
}
// FunctionOne, passes by value
SimpleCat FunctionOne(SimpleCat theCat)
{
cout << "Function1 returning,,,\n";
return theCat;
}
//FunctionTwo, passes by reference
SimpleCat* FunctionTwo (SimpleCat *theCat)
{
cout << "Function2 returning,,,\n";
return theCat;
}
is FunctionTwo receiving the object by reference or by pointer?
Anyone?
--
Best regards
Robert Tag: CListBox item's color Tag: 251595
Passing an object pointer to function
Hi,
Below I am passing an object to a function by reference. Please consider the
following code fragment:
#include <iostream>
using namespace std;
class SimpleCat
{
public:
SimpleCat();
~SimpleCat();
int GetAge() {return itsAge;}
void SetAge(int age) {itsAge = age;}
private:
int itsAge;
};
SimpleCat::SimpleCat()
{ cout << "Constructor called. \n";
itsAge = 1; }
SimpleCat::~SimpleCat()
{ cout << "Destructor called \n"; }
void Function1(SimpleCat *pRags);
int main()
{
int a;
SimpleCat Frisky;
Function1(&Frisky);
cout << Frisky.GetAge();
}
void Function1(SimpleCat *pRags)
{ pRags->SetAge(50); }
The above code works fine, however what if in main I wanted to create a
pointer to an object on the heap using the following line:
SimpleCat * pRags = new SimpleCat;
and then passing only the pointer of the object to my function: Please
consider the following code which does not complile?
#include <iostream>
using namespace std;
class SimpleCat
{
public:
SimpleCat();
~SimpleCat();
int GetAge() {return itsAge;}
void SetAge(int age) {itsAge = age;}
private:
int itsAge;
};
SimpleCat::SimpleCat()
{
cout << "Constructor called. \n";
itsAge = 1;
}
SimpleCat::~SimpleCat()
{
cout << "Destructor called \n";
}
void Function1(int *pRags);
int main()
{
int a;
SimpleCat * pRags = new SimpleCat;
Function1(&pRags);
cout << Frisky.GetAge();
}
void Function1(int *pRags)
{
pRags->SetAge(50);
}
I don't know if this is possible to do in VC++. And since I am passing a
pointer to an object on the heap, is my function prototype an header correct?
void Function1(int *pRags)
I am sorry if this is a stupid question but the book examples somehow don't
go into this probability, so I am just being curious!
Anyone, all help greatly appreciated!
--
Best regards
Robert Tag: CListBox item's color Tag: 251579
How to get Computer Name given IP address?
Hi,
I'm writing a program that is running on a network and it has to "discover"
the names of the other computers on the network in that same workgroup. The
good thing is that it knows all the IP addresses of the computers on the
network for which it wants the names. Is there a function that will allow
me to do this?
I'm aware of this:
BOOL GetComputerName(
LPTSTR lpBuffer, // address of name buffer
LPDWORD nSize // address of size of name buffer
);
It is however only useful on the computer where my code runs, not for
getting the names of the others.
The network is a regular Client For MS Networks with Workgroup (No Domain)
running.
Thanks,
RussR Tag: CListBox item's color Tag: 251577
VC++ and Visual Source Safe
Sorry about being off topic, but I get no help on the VSS groups.
I want to move my VC6 projects off my local drive and up to our network.
Redundant backups, since we also use VSS on the network.
When I open a moved project, Visual Studio 6 no longer recognizes it as
being under source control. I have set the "default directory" in VSS to
point to the new location. What else do I need to do to synch VSS and VC
again?
Thanks Tag: CListBox item's color Tag: 251574
.dll refuses to unload
Hello all,
I am calling LoadLibrary() exactly once to dynamically load a .dll. I see
the DLL_PROCESS_ATTACH section of DllMain() being entered exactly once.
Later, I call FreeLibrary() to unload that .dll. However, the
DLL_PROCESS_DETACH section of DllMain() does not get invoked. Furthermore,
destructors of static objects in the .dll are not executed. So, it appears
that the .dll is just not unloading for some reason. The reference count for
this .dll should be at 0 since I've confirmed that LoadLibrary() and
FreeLibrary() are both being called exactly once, and in that order.
What are some possible causes of this problem?
How can I confirm that the reference count is indeed going to 0?
Thanks,
Dave Tag: CListBox item's color Tag: 251571
Different version # and different configurations
I want to apply a different version # to a specific configuration to my
project.
For example, I have 2 configurations, 1st edition and 2nd edition. For 1st
edition I want to use 7.2.100.3 as the version and 7.2.200.7 for the second
version.
Is there a way to assign a version to a specific configuration? I created a
second version in the Resources area, but dont know where to assign it to the
specific configuration.
I"m using VS6.0
Thanks.
-C Tag: CListBox item's color Tag: 251568
Any merits of virtual operators?
Hello,
I'd like to ask a question, which is somewhat theoretical.
As we all know, many overloaded operators can be virtual.
The more I think about it, the more I wonder what can be a
possible scenario where I need virtual operator. So far,
here are the points:
1. Overloaded operator must have at least one parameter
whose type is class or reference to class. So, derived class
will have other type for that parameter, hence virtuality
doesn't give us anything.
2. If I declare operator in derived class with same
signature (with covariant return type, probably), then
inside operator's body I need to determine actual type of
the argument (by means of RTTI or others) in order to
perform operation correctly.
3. When deriving new class I'll need to overload virtual
operator with all base types, which occur in hierarchy. So,
with each new derivation operators will grow as snowball.
All above mentioned issues can be solved easily and
elegantly with regular virtual functions. What you guys
think about it?
Thanks in advance
Alex Tag: CListBox item's color Tag: 251565
Loaded DLLs
Hello all,
For a given process, how may I get a snapshot at an instant in time of what
DLLs it has loaded? This question is asked in the context of VC++ 6.0.
Thanks,
Dave Tag: CListBox item's color Tag: 251560
wav file format
Hello,
I am trying to write a *.wav file. I read about its format and now I can
write a *.wav file but when I am trying to play it with Media player, it
reports that the file is corrupted which I think means that there is a
problem on the file format but I couldn't find what is it. Is there any
application that could read a wav file and report if there is any problem in
its format?
Is there any code that helps me to find what I can use to write a wav file?
Any help is very appreciated.
Best regards Tag: CListBox item's color Tag: 251559
How to I change between 2 printers.
I have a VC++ program that currently prints to one printer exactly how I
want it to using the CreatePrinterDC method.
However, now I need to be able to direct different print jobs to different
printers either on the machine or on the network.
How do I get a device context for these other printers that are not the
default printer?
And how do I tell one printer from another under program control?
Can someone point me to an example?
Charles L. Tag: CListBox item's color Tag: 251555
Dynamically Set Menu Item Text
Hi,
Does anybody know if there is a way to dynamically set the menu item
text in MFC?
Thanks
Marcus de Leon Tag: CListBox item's color Tag: 251549
validating input file streams
This may seem like a stupid question, but there's always something that has
bothered me about this. If I'm using an ifstream object to read from a file,
are there any other standard checks I should use besides is_open() before
attempting to read from the file? I recall that in VC6 there was a fail()
check that I've seen used a lot with is_open(), but I can't seem to find that
in the current standard (not that I'm suggesting fail() and is_open() would
be completely sufficient when used together).
Is it smarter to use try-catch around a read attempt, catching the
"failure"? I'm just afraid that there is the possibility of opening an
"invalid" file (whatever that means), and is_open() would still return true.
Am I looking too far into this?
Thanks in advance. Tag: CListBox item's color Tag: 251548
ITaskScheduler::Enum 80070005
Hi All,
Just revisiting a problem I had back in April, and I've still not found a
solution.
I'm trying to work with the Task Scheduler from a VC++ .NET application on a
single Windows 2003 SP1 server, and I'm running into an error when trying to
enumerate the list of scheduled tasks using this code:
CComPtr< ITaskScheduler > pITS;
TESTHR( CoCreateInstance(CLSID_CTaskScheduler,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITaskScheduler,
(void **) &pITS ) );
CComPtr< IEnumWorkItems > pIEnum;
TESTHR( pITS->Enum(&pIEnum) );
The resulting HRESULT is -2147024891 (0x80070005), which is Access Denied,
so I'm wondering what I need to change to get this to work...
Do I have to use impersonation when creating the instance of the Scheduler?
Do I need to run the Task Scheduler under a different Log On than the Local
System account? Do I need to change the Security or Activation (currently a
Library application) of my COM+ application?
Any pointers would be appreciated.
Regards...Andrew Tag: CListBox item's color Tag: 251545
Virtual functions not calling higher class
Hi,
I am working using VS 7.1 and have the following problems;
class CBase
{
[...]
protected:
virtual void OnCallback_Enter(int rc) {};
virtual void OnSys_Enter(int rc);
static void AWAPI_enter( );
}
class CBot : public CBase
{
[...]
protected:
virtual void OnCallback_Enter(int rc);
}
void
CBase::OnSys_Enter(int rc)
{
[...]
OnCallback_Enter( );
}
OnCallback_Enter always calls the CBase version, depsite one being available
in CBot, when I make the CBase version pure virtual the OnSys_Enter function
complains about calling a pure virtual function.
This all seems like it is setup correctly to me, so why would I be
experiencing the error; or have I missed something obvious.
--
- Mark Randall
http://zetech.swehli.com Tag: CListBox item's color Tag: 251543
I can't pass CString or wstring to other project.
Hi, I've had sub-project.
When I made a method which has 2 or 3 CString or std::wstring parameters,
it can pass it without any problem.
But, when I tried to make that kind of method in other project,
(it's tied by Dependency and I've set Unicode, Multi-Thread Dll Debug. All
Project have same settings)
it makes that kind of link error.
ClassWizard error LNK2019: unresolved external symbol "public: class
ATL::CStringT<wchar_t,class StrTraitMFC_DLL<wchar_t,class
ATL::ChTraitsCRT<wchar_t> > > __thiscall
maymfc::CPathInfo::GetFolderPath(enum maymfc::CPathInfo::FolderType)"
(?GetFolderPath@CPathInfo@maymfc@@QAE?AV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@W4FolderType@12@@Z)
referenced in function "private: void __thiscall
CClassWizardDlg::InitTheme(void)" (?InitTheme@CClassWizardDlg@@AAEXXZ)
(I tried to call CPathInfo::GetFolderPath() ( it return CString. ) from
CClassWizardDlg class.
The class method looks weird but, it just pilot program, anyway. :) )
So, what is the problem?
Before I try to UNICODE, that kind of problem doesn't happen, I guess.
Thanks in advance. Tag: CListBox item's color Tag: 251541
turning off lnk 4006
Hi All,
Im sorry if this is OT, if it is, kindly point me the way, please ?
I get quite a few lnk4006 warnings from my project, which uses
some old c libraries. This is ok though, as Im forcing it with
/FORCE:multiple. I cant seem to be able to tell the VC6
compiler to shut up, however and printing these warning
messages takes up almost 10% of the compilation-time.
Anyone know how to silently pass by these warningmessages ?
thanks,
Jonathan Tag: CListBox item's color Tag: 251539
This Do Modal loop - is it safe? Any comments (except, "mmnn, why don't you just use a modal dialog?")
Is the following 'DoModal' safe? It seems to work on Win2K.
void CGeneralWindow::DoModalMessagePump(void){
m_bIsDoingModal= true;
// Enter the message loop
MSG msg;
ZeroMemory(&msg, sizeof(msg));
while(m_bIsDoingModal){
if(GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else{
// Re-post the message that we retrieved
PostQuitMessage(msg.wParam);
m_bIsDoingModal= false;
return;
}
}
}
Elsewhere in the window code is this snippet from a WM_COMMAND handler.
Essentially, the only way the window ends its 'modal' life is when one of
it's two buttons is clicked (or the app quits elswhere) - a tray menu.
So, here, if its the OK button, I reset the 'doing modal' flag, fade the
window away (in SetShow(false)) and then destroy the window. Any messages
not handled in the local message pump (such as all the destroy non client
messages etc.) get handled in the main app message pump (or the next 'modal'
window).
if(idCtrl == IDOK){
// signal to break out of local modal loop
m_bIsDoingModal= false;
SetShow(false);
DestroyWindow(m_hwnd);
m_hwnd= NULL;
} Tag: CListBox item's color Tag: 251536
Moving files in C++ using Windows SDK
Hi,
What am I trying to achieve is to move a directory (or a set of files using
wildcards) from one computer on the network to the computer that the code
that's doing the moving is running. The systems are running WindowsXP
Professional. Permissions on each directory is set to FULL for Everyone.
So for example, \\computerA runs a code that will move the directory,
\\computerB\\apps to c:\apps, where c:\apps is on computerA.
Here's the line of code that I'm using which I got from the Windows SDK at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/movefileex.asp
void main() {
//here's the line of code that does the moving
int result= MoveFileEx("\\\\computerB\\apps","c:\\apps",
MOVEFILE_COPY_ALLOWED |
MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
//this is to print out the error message when it fails
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
printf("%s\n",lpMsgBuf);
// Free the buffer.
LocalFree( lpMsgBuf );
}
I get an error message usually saying access denied. Permissions are all
set full for everyone, so I'm stumped. If I change it to copy from one
directory on my computer to another directory on my computer, it only works
if the target directory doesn't already exist. If it does exist, I get an
access denied error....why? I've set all the MOVEFILE flags to avoid this.
Thanks,
RussR Tag: CListBox item's color Tag: 251529
Error while calling the function HrESERestoreAddDatabase
Hello All,
I am writing an application to backup and restore M.S. Exchange server
programatically. I am using the Exchange Backup and Restore API and am
developing the application in VC++ 6.0 on a Windows Server 2003 Enterprise
Editioon. I am able to do the backup successfully but I am getting error in
the function "HrESERestoreAddDatabase" during the resore. I am trying to call
the function HrESERestoreAddDatabase as follows:
typedef HRESULT (ESEBACK_API *HrESERestoreAddDatabase) (IN HCCX
hccxRestoreContext,IN WCHAR * wszDatabaseDisplayName,IN GUID guidDatabase,IN
WCHAR * wszDatabaseStreamsS,OUT WCHAR ** pwszDatabaseStreamsD);
HrESERestoreAddDatabase fnMNURestoreAddDatabase = NULL;
fnMNURestoreAddDatabase = (HrESERestoreAddDatabase) GetProcAddress
(g_hESEDll,"HrESERestoreAddDatabase");
if(fnMNURestoreAddDatabase)
hr = (fnMNURestoreAddDatabase) (phccxMNURestoreContext,
szMNUDatabaseDisplayName, guidMNUDatabase, wszMNUDatabaseStreamsS ,
&pwszDatabaseStreamsD);
if(hr != S_OK)
{
DWORD dwError = GetLastError();
LPVOID lpMsgBuf;
DWORD dw = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,0,NULL);
CString strMessage;
strMessage.Format(_T("failed with error %d : %s"),dw,lpMsgBuf);
AfxMessageBox(strMessage);
LocalFree(lpMsgBuf);
return MNU_EXCHANGE_RESTORE_FAILURE;
}
All the inputs are correct.
Output:
hr = -939647167
dw = 0 The operation completed successfully.
Expected Output:
hr = S_OK
I am getting hr which is not equal to S_OK but the GetLast Error returns 0
which corresponds to "The operation completed successfully.". Can anyone
please point the mistake in my code or give me sample code for the
"HrESERestoreAddDatabase" Function?
Thanks,
Viraj
a.viraj@mobiliti.com
http://www.mobiliti.com
732-248-8300 ext 234 Tag: CListBox item's color Tag: 251528
error C2065/error C3861: 'm_nBackStyle': identifier not found, eve
Dear Experts,
I need to compile an old project (built with VC++) in Visual Studio .Net
2003.
The project is going to build a DLL. When i try to compile the project, i
got the following errors:
c:\thepath\aaa.cpp(890): error C2065: 'm_nBackStyle' : undeclared identifier
c:\thepath\aaa.cpp(890): error C3861: 'm_nBackStyle': identifier not found,
even with argument-dependent lookup
c:\thepath\aaa.cpp(891): error C3861: 'm_nBackStyle': identifier not found,
even with argument-dependent lookup
c:\thepath\aaa.cpp(892): error C3861: 'm_nBackStyle': identifier not found,
even with argument-dependent lookup
in aaa.cpp, 'm_nBackStyle' are used as the following:
// Set up background mode.
890: if(m_nBackStyle != 1 && m_nBackStyle != 2)
891: m_nBackStyle = 2;
892: SetBkMode(di.hdcDraw, m_nBackStyle);
in aaa.h, i have:
#include <atlctl.h>
and aaa.h is already included in aaa.cpp.
I found the following declaration in ddd.h, which is in another project (the
solution has sevreal projects):
LONG m_nBackStyle;
Is it because my project is not set correctly? When i tried to open it in
Visual Studio .Net 2003, i was asked to transfer the project, i wonder if
after the transfer, the dependence relationship of the projects was lost.
I found some info about m_nBackStyle at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceatl/htm/cccontrl_72.asp
Could you please help me fix the problem. Thanks a lot!
Vic Tag: CListBox item's color Tag: 251527
VC6 MSDN
I had to reinstall my Visual Studio 6 and I can't remember which version
of MSDN was the last to support it. July 2001 maybe? Anybody know?
Thanks Tag: CListBox item's color Tag: 251522
exception in std?
Compiling the following lines with Visual C++.Net Version 7.1.3088
I get the following error:
error C2874: using-Deklaration verursacht eine mehrfache Deklaration von
'a::exception'
(using-declaration causes a multiple declaration of 'a::exception')
#include <exception>
namespace a
{
struct exception{};
}
using a::exception;
int main()
{
exception b;
}
I thought that the 'regular' exception is defined in namespace std.
So these lines shouldn't be a problem.
What am I doing wrong?
Thanks a lot,
Thomas Tag: CListBox item's color Tag: 251521
Scanner and WIA
Hello, All!
I'm trying to scan documents using WIA 1.0. And I have a problem.
I access a scanner as described in MSDN's WIA Tutorial. When I call
WriteMultiple() method to set some scanner options (resolution, color depth
and so on) I get error E_INVALIDARG. No matter what combination of
parameters I use I got the same error.
But if I run any other application which uses a scanner and then run my
application WriteMultiple returns S_OK, though not every parameters are set
after this.
Who can help me with WIA?
---
With the best regards, Mahoney. Tag: CListBox item's color Tag: 251520
Env: VC++6
Is it possible to change CListBox's color by every item while calling
CListBox::AddString()?
>Is it possible to change CListBox's color by every item while calling
>CListBox::AddString()?
Not directly. You'd have to make the control owner-drawn and implement
all the associated handlers for starters and store some information
(in the item's lParam value perhaps) to indicate the colour.