|
Hello everyone,
I am studying the manual for DLLMain, it is mentioned,
http://msdn2.microsoft.com/en-us/library/ms682583.aspx
--------------------
If your DLL is linked with the C run-time library (CRT), the entry point provided by the CRT calls the constructors and destructors for global and static C++ objects. Therefore, these restrictions for DllMain also apply to constructors and destructors and any code that is called from them.
--------------------
My questions are,
1. How could I know if a project whether DLL or EXE or static lib is linked with C Runtime library?
2. Why we need C Runtime library in a C++ project? We need to call some legacy C functions like printf other than pure C++ functions std::cout?
3. If we use default entry point in DLL (DllMain), does it mean C Runtime Library is dynamically linked?
thanks in advance,
George
|
|
|
|
|
George_George wrote: 1. How could I know if a project whether DLL or EXE or static lib is linked with C Runtime library?
It depends on the version of Visual Studio you are using. In general, right-click on the project, select Properties, and then look through the compiler and linker options. In all likelihood you are linking with the C runtime library.
George_George wrote: 2. Why we need C Runtime library in a C++ project? We need to call some legacy C functions like printf other than pure C++ functions std::cout?
The C/C++ libraries are pretty intertwined. "std::cout " isn't a 'pure C++ function' which is provided by the compiler; it's a function in the C++ library. The C++ library has the same DllMain restraints.
George_George wrote: 3. If we use default entry point in DLL (DllMain), does it mean C Runtime Library is dynamically linked?
No. The two don't have anything to do with each other. The C runtime library is dynamically linked when you link with the import library for it's DLL. It is statically linked when you link with the object library directly. Which you do is selected by compiler and linker options.
|
|
|
|
|
Thanks Gary!
Great reply! Two more comments,
1.
Gary R. Wheeler wrote: It depends on the version of Visual Studio you are using. In general, right-click on the project, select Properties, and then look through the compiler and linker options. In all likelihood you are linking with the C runtime library.
Which IDE are you using? I am using Visual Studio 2008, and it is appreciated if you could show me your option in your IDE. If you are using other version of Visual Studio, I think it should be similar. I have checked compiler and linker option one by one, but can not find the result.
2.
Gary R. Wheeler wrote: The C++ library has the same DllMain restraints.
What do you mean "DllMain restraints"?
regards,
George
|
|
|
|
|
"restraints" = "restrictions". Look at the quote you made in your initial post.
Iain.
Iain Clarke appearing by Special Request of CPallini.
|
|
|
|
|
|
If the documentation says so, I'd do no better than to look at it too.
I think one of the combinations has to do with being thread safe too, but again, msdn will be more authorative than me.
Iain
Iain Clarke appearing by Special Request of CPallini.
|
|
|
|
|
Thanks Iain,
I just want to confirm with you since MSDN document is not describing always explicitly.
regards,
George
|
|
|
|
|
Iain Clarke wrote: one of the combinations has to do with being thread safe
All of the run-time libraries are thread-safe now. I believe they dropped the non-thread-safe versions after VC6.
|
|
|
|
|
Well, some of us are Luddites, and still use VC6.
If it wasn't for Windows Mobile programming, I'd still be using 6 for all my work, instead of most.
But I'm glad to know they've finally made their library re-entrant. I was quite schocked to find it wasn't...
Iain.
Iain Clarke appearing by Special Request of CPallini.
|
|
|
|
|
Hi all
I want to copy some file(like .dll ,.exe etc) from some perticular location and paste to another location and i m using Shellexecute but it is not working. so can u help me out get it done.
shellexecut(m_hwd, "copy", "Path of the source directory","path of the destination directory",NULL,NULL);
Thanks in advance
RYK
|
|
|
|
|
|
Here is the code:
<br />
#define PP_CAT(a,b) PP_CAT_(a,b)<br />
#define PP_CAT_(a,b) a##b<br />
<br />
#define PP_STR(s) PP_STR_(s)<br />
#define PP_STR_(s) #s<br />
<br />
<br />
class CNamedTreePropertyBase<br />
{<br />
public:<br />
CNamedTreePropertyBase() : name(0), pParent_(0) {}<br />
CNamedTreePropertyBase(const TCHAR * const Name, <br />
CNamedTreePropertyBase *pParent) : name(Name)<br />
, pParent_(pParent) {}<br />
<br />
const TCHAR *const name;<br />
virtual const TCHAR const *GetName() const = 0;<br />
CNamedTreePropertyBase *pParent_;<br />
};<br />
<br />
<br />
#define NAMED_PROP(Type, Var, InitialVal, pParentProp) \<br />
class PP_CAT(tag, Var) : public CNamedTreePropertyBase \<br />
{ \<br />
public: \<br />
const TCHAR * const name; \<br />
Type value; \<br />
PP_CAT(tag, Var) () : name(PP_STR(Var)) \<br />
, value(InitialVal) \<br />
, CNamedTreePropertyBase(name, pParentProp) {} \<br />
const TCHAR const *GetName() const {return name;} \<br />
} Var; \<br />
<br />
<br />
struct A<br />
{<br />
NAMED_PROP(std::string, prop, _T("some value"), 0);<br />
NAMED_PROP(std::string, child_prop, _T("some value"), reinterpret_cast<CNamedTreePropertyBase*>(&prop));<br />
};<br />
The MSVC 6.0 compilier, and it issues an error:
E:\Projects\Sources\TestVarName_1.0_question\TestVarName.cpp(56) : error C2440: 'reinterpret_cast' : cannot convert from 'class A::tagprop A::*' to 'class CNamedTreePropertyBase *'
There is no context in which this conversion is possible
How can it be possible to convert the pointer correctly?
|
|
|
|
|
|
Hello everyone,
There are two scale parameter in perfmon tool and I am not sure how to calculate the real value of working set bytes from the two scale parameters. Could anyone help please?
The two scale parameters are,
1. At the bottom of perfmon main screen, there is a scale column
2. Properties dialog --> Graph Tab --> Vertical Scale
If I set Vertical Scale max to 1,000,000 and the scale column for working set is 0.0000100, and the current value of displayed working set is 4000, what is the real bytes of working set?
thanks in advance,
George
|
|
|
|
|
I have a question :
Why do you need to calculate the real values of the working sets?
|
|
|
|
|
I need to get the real (actual) value of physical memory consumed. Any idea about my original question, Maximilien?
regards,
George
|
|
|
|
|
two project A and B connect by socket
A:
<br />
int iSend = send(sock,buf,1024*16,0); <br />
B:
<br />
fd_set fdread, fdExcept;<br />
FD_ZERO(&fdread);<br />
FD_ZERO(&fdExcept); <br />
FD_SET(ssock,&fdread); <br />
FD_SET(ssock,&fdExcept); <br />
<br />
int iRet = select(0, &fdread, NULL, &fdExcept, &timeOut);<br />
<br />
<br />
if(iRet < 1) <br />
{ <br />
break;<br />
} <br />
else<br />
if(FD_ISSET(ssock,&fdExcept)) <br />
{ <br />
<br />
break;<br />
} <br />
else<br />
if(FD_ISSET(ssock,&fdread)) <br />
{<br />
<br />
<br />
<br />
char buf[1024*16] = {0};<br />
<br />
iRecv = recv(ssock, buf, 1024*16, 0);<br />
}<br />
<br />
if B not use select, but only use
<br />
iRecv = recv(ssock, buf, 1024*16, 0);<br />
and that iRecv equals 1024*16
|
|
|
|
|
For stream-oriented protocols...
A recv() call is successful if the return value is anything
except 0 or SOCKET_ERROR. It's up to you to keep track of
how many bytes are received each call and call recv()
additional times if necessary until the amount of data you
are expecting is received.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Is there a way of setting keys, like HKey_LOCAL_MACHINE from a remiote terminal on a LAN, on another machine. I assume full adminitrator Access Rights from the calling machine. Is there a non destructive remote Read Way with fewer access rights to read from Similar key.
Regards
Bram van Kampen
|
|
|
|
|
you can try RegConnectRegistry
|
|
|
|
|
Among the services, there is one named RemoteRegistry. In order to access the registry of another computer, you need that service properly configured both on your computer and the remote computer.
|
|
|
|
|
I'm working on setting up a menu to choose which type of sort is wanted, as well as how many numbers in the array, and the numbers for the array.
Trying to figure out how to get my values into the array isn't going according to the examples in the book. I could really use help!
I've pasted my code below.
Thank you!
#include <iostream>;
using namespace std;
// Function prototypes
void selectionSort(int [], int);
void showArray(int [], int);
void sortArray(int [], int);
void showMenu ();
void displayName();
void numberOfValues(int);
void enterValues(int);
int main()
{
int choice; // To hold a menu choice
// Find out the type of sort wanted
do
{
// Display the menu and get the user's choice.
showMenu();
cin >> choice;
if (choice != 3)
{
if (choice = 1)
numberOfValues(int numbers);
enterValues();
sortArray(int [], int);
else if (choice = 2)
numberOfValues(numbers);
enterValues();
selectionSort();
}
}
}while (choice !=3);
Return 0;
}
}
//**************************************************************
// Definition of function selectionSort. *
// This function performs an ascending order selection sort on *
// array. size is the number of elements in the array. *
//**************************************************************
void selectionSort(int array[], int size)
{
// Display the values.
cout << "The unsorted values before the first selection pass are:\n";
cout << "\t\t\t ";
showArray(values, SIZE);
int startScan, minIndex, minValue;
int x = 1;
for (startScan = 0; startScan < (size - 1); startScan++)
{
minIndex = startScan;
minValue = array[startScan];
for(int index = startScan + 1; index < size; index++)
{
if (array[index] < minValue)
{
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[startScan];
array[startScan] = minValue;
cout << "After pass #" << x << " the values are ";
showArray(array, index);
x = x + 1;
// Display the values again.
cout << "The final sorted values for this selection sort are:\n";
cout << "\t\t\t ";
showArray(array, SIZE);
}
// Display the values.
cout << "The unsorted values before the first bubble pass are:\n";
cout << "\t\t\t ";
showArray(array, SIZE);
sortArray(array, SIZE);// Sort the values.
// Display them again.
cout << "The final sorted values for this bubble sort are:\n";
cout << "\t\t\t ";
showArray(array, SIZE);
//return 0;
}
//***********************************************************
// Definition of function sortArray *
// This function performs an ascending order bubble sort on *
// array. size is the number of elements in the array. *
//***********************************************************
void sortArray(int array[], int size)
{
bool swap;
int temp;
int x = 1;
do
{
swap = false;
for (int count = 0; count < (size - 1); count++)
{
if (array[count] > array[count + 1])
{
temp = array[count];
array[count] = array[count + 1];
array[count + 1] = temp;
swap = true;
}
}
cout << "After pass #" << x << " the values are ";
showArray(array, 6);
x = x + 1;
} while (swap);
}
//*************************************************************
// Definition of function showArray. *
// This function displays the contents of array. size is the *
// number of elements. *
//*************************************************************
void showArray(int array[], int size)
{
for (int count = 0; count < size; count++)
cout << array[count] << " ";
cout << endl;
}
void showMenu ()//choose type of sort to do
{
cout << "What would you like to do?\n";
cout << "\t1\tBubble Sort\n";
cout << "\t2\tSelection Sort\n";
cout << "\t3\tQuit\n";
cout << "Enter your selection:\n";
cin >> selection;
}
void displayName()
{
cout << "This program was created by Laura Sullivan.\n";
}
void numberOfValues(int numbers)
{
int numbers; //size of array
cout << " How many values do you want in the array (enter 6, 7, 8, 9 only):\n";
cin >> numbers;
}
void enterValues()
{
int numbers; //size of array
const int SIZE = numbers;
int values[SIZE] = {numbers};
cout << "Enter your values (0 through 9), with a space between each value:\n";
cin >> values[numbers];
}
|
|
|
|
|
Do you know that equality test operator is == (while = is the assignment operator)?
BTW use <pre> tags to enclose code snippets, for instance:
<pre>
</pre>
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Hello everyone!
Miss me? No? Aww.
Anyway, I'm trying to make a very simplistic Paint clone. I have a question: I trap mouse drawing with WM_MOUSEMOVE. However, it draws in dots, as in, if I want a doodle I have to go very slowly. How would I fix this? Maybe interpolating; drawing a line between the previous and current dots? But that would be very squareish...
Can somebody fill me with their wisdom so I can figure this out? Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Windows does not send the application a WM_MOUSEMOVE message for each pixel the mouse pointer passes on, hence you have to deal with a discrete set of disconnected points. You can either (as you realized) connect them with straight lines the obtained point or use some curve (for instance splines) to make the path appear smoother.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|