|
Did you not see my question here? Posting questions/replies here takes a lot more time than it does to just search for the answer.
gethostname()
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
You have the answer in your question itself
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
but i don't know use parameter in that funtion :
GetComputerName(...);
could you help me ???
|
|
|
|
|
hi ,
This is the Snippet of Code
//===========================================================
#define INFO_BUFFER_SIZE 32767
TCHAR infoBuf[INFO_BUFFER_SIZE];
DWORD bufCharCount = INFO_BUFFER_SIZE;
GetComputerName( infoBuf, &bufCharCount);
//==========================================================
the infoBuf contains the Computer Name. good luck.
cheers.
uday kiran
|
|
|
|
|
Thank you very and very much !!!
|
|
|
|
|
Could you tell me : How to get my IP address ???
What's happened if my computer don't connect to the Internet or LAN, or i don't install IIS ???
And:
If i connect over LAN,
how to get other Computer name if i know its IP
and how to get other computer's IP if i know its name ?
|
|
|
|
|
<br />
#define INFO_BUFFER_SIZE 32767<br />
LPSTR computerName = new char(50);<br />
dw = INFO_BUFFER_SIZE;<br />
GetComputerName(computerName,&dw);<br />
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
VuNic wrote: #define INFO_BUFFER_SIZE 32767
What's wrong with using the system-defined MAX_COMPUTERNAME_LENGTH ?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
what's MAX_COMPUTERNAME_LENGTH ?
what is its value ?
|
|
|
|
|
Surivevoli wrote: what's MAX_COMPUTERNAME_LENGTH ?
what is its value ?
Do you just refuse to look anything up for yourself? Look in WinBase.h for this value.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Hi everybody
I am trying to get a program of mine to do a acceptable Axis-resolution computation. The software is intended to diplay standard graphs (value over item production id) and gaussian evaluations (i.e. "do we achieve gaussian distribution").
I have a problem with the axis computation, though. I am looking for a clever way to guarantee that (with a given max_Y and max_X) my axis ticks are useful.
This is what I have written so far:
<br />
void static calculateAxis(int& Min, int& Step, int& Max)<br />
{<br />
int Size = Max - Min;
for(int i = 1; ; i *= 10)
{<br />
bool abort = false; <br />
for(int j = i; j < 10 * i ; j += i)
{<br />
if (Size < j)
{<br />
Step = j / 10;
if (Min < 0)
{<br />
Min = Min - (Min % (j / 10)); <br />
Min -= (j / 10);<br />
}<br />
else Min = (Min/i)*i; <br />
<br />
if (Step == 0) Step = 1;
if ((Max % Step) > (Step / 2)) <br />
if ( (j-i) > 0 ) <br />
Step = (j-i) / 10;
abort = true;
break;<br />
}<br />
}<br />
if (abort) break;<br />
}<br />
}
My problem here is: I totally forgot that my Y_Max could be something like "0.44", which makes my integer-based approach useless.
Any suggestions, hints or links would be welcome.
Edit:
I think I forgot to make this clear
What I get when I "hard"-divide a max-val by 10 is not useful to be. Noone would be able to
derive values from that diagram if the corresponding "axis tick"-label reads 1283.34 and the
increment for each tick is 641.7-something. I need "readable" tick-labels. Thats what I am after.
Edit2: Tried to add some explanatory comments.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
-- modified at 5:09 Monday 24th April, 2006
|
|
|
|
|
It is difficult to understand your code (you should have explained it a little bit).
Anyway, I developped my own charting control also and of course I developped also a 'clever' way of displaying the ticks (taking anything as min and max values for the axis). The ticks are readable values. Here is the code:
void CGraphAxis::CalculateBestTicks()
{
if (m_bIsLogarithmic)
m_TickIncrement = 10;
else
{
int PixelSpace;
if (m_bIsHorizontal)
PixelSpace = 25;
else
PixelSpace = 20;
int MaxTickNumber = (int)fabs((m_EndPos-m_StartPos)/PixelSpace);
float TempTickSpace = (m_MaxValue-m_MinValue)/MaxTickNumber;
int Zeros = (int)floor(log10(TempTickSpace));
float MinTickSpace = pow(10,Zeros);
int Digits = 0;
if (Zeros<0)
{
Digits = (int)fabs(Zeros);
}
if (MinTickSpace>=TempTickSpace)
{
m_TickIncrement = MinTickSpace;
SetDecimals(Digits);
}
else if (MinTickSpace*2>=TempTickSpace)
{
m_TickIncrement = MinTickSpace*2;
SetDecimals(Digits);
}
else if (MinTickSpace*5>=TempTickSpace)
{
m_TickIncrement = MinTickSpace*5;
SetDecimals(Digits);
}
else if (MinTickSpace*10>=TempTickSpace)
{
m_TickIncrement = MinTickSpace*10;
if (Digits)
SetDecimals(Digits-1);
else
SetDecimals(Digits);
}
}
if (m_bIsLogarithmic)
{
int LogBase = (int)log10(m_MinValue);
m_FirstTickVal = pow(10,LogBase);
}
else
{
m_FirstTickVal = 0;
if (m_TickIncrement!=0)
{
if (m_MinValue == 0)
m_FirstTickVal = 0;
else if (m_MinValue>0)
{
m_FirstTickVal = (int)(m_MinValue/m_TickIncrement) * m_TickIncrement;
while (m_FirstTickVal<m_MinValue)
m_FirstTickVal += m_TickIncrement;
}
else
{
m_FirstTickVal = (int)(m_MinValue/m_TickIncrement) * m_TickIncrement;
while (m_FirstTickVal>m_MinValue)
m_FirstTickVal -= m_TickIncrement;
if (!(m_FirstTickVal == m_MinValue))
m_FirstTickVal += m_TickIncrement;
}
}
}
}
Explanation of how it works:
First, just look at the non logarithmic part. m_StartPos and m_EndPos are the screen position of the axis and m_MinValue and m_MaxValue are the min and max values respectively.
I first know that a 'good' space between the ticks (in screen coordinates) are 25 or 20 pixels (for horiz or vertical axis). Then, knowing that I calculate the number of ticks (knowing the size of the axis) and the space (in value) between the ticks. These are temp values (the resulting values will need to be as close as possible to these values).
Then, I calculate the space (in values) between ticks but no rounded on strange values (like you described) but on something like 1, 2 or 5*10^X where X is optimalized for showing the most significant digits. Then after that I calculate the number of digits that will be displayed on the ticks label (this is used when you have ticks separated by less than 1).
Finally, we need to calculate the first tick value because your axis can start anywhere and not necessarily on a tick.
Hope this helps
|
|
|
|
|
Thanks.
That is pretty much where I was aiming. I did a similar thing with my "clever axis", I just was not clever enough to think about floats right from the beginning
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
I do have one more question, though: What does SetDecimals do in your implementation?
Thanks in Advance
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
It is only used to set the number of decimal places that will be displayed for the ticks label. so, it is not important here.
-- modified at 8:43 Wednesday 26th April, 2006
OT: I'm currently working on an article. Soon, I will share this control on codeproject.
|
|
|
|
|
I'm sorry if the title is a bit off, but what I'm looking for none of my books talk about.
I have a simple shell of a project where I have defined a set of pure virtual functions. Now from what I know to use a class that is derived from the abstract class, you must know the derived class name.
Example:
VirtualTime *pTime;
ptime = new Clock;
So Clock implements all the virtual functions defined in VirtualTime. Straight forward, nothing tricky, ANSI C++ stuff.
Here's my delima. In the code above you must know that "Clock" class exists in the project. This presents a problem when the user specifies the class derived from the abstarct class during runtime.
The obvious solution is to add a simple switch/case logic and list out all the known derived classes. However this is ugly and requires more work for little gain for the developer. What I want is the developer to code up the class implementing the vrtual functions, add the files to the source code base, then compile/link, and then run. No need to add the class name to some internal library of derived classes.
Example:
Developer codes up Clock, Watch, and Timer in three seperate class files. There is no need to change any other code. Then at runtime the user specifies the Watch class and the pTime pointer instaniates the Watch class.
I've read up on dynamic casting, but the problem is you still need to know the derived object name. As with any casting from the articles that I have read.
So I'm looking for a way to dynamically instantiate unknown classes, validate the class exists at runtime, and that the validated class is indeed derived from my virtual function class.
No need to post code (unless you have it handy and feel generous). Links to articles or Google search terms to send me on my way would be appreciated greatly.
|
|
|
|
|
|
I used a technique like that for one of my project, here is how it works (sorry, I don't have any link). You'll have to create a factory class that will manage the construction of the derived classes. This factory is basically a wrapper class around a map (the map link the name or the id of the inherited class and a function that is responsible of the creation of the class). So, when you want to create a class, you call a function from your factory (specifying the name or id, or...) of your class. The factory will then search in the map for the corresponding entry in the map and call the creation function (which is not part of the factory) and return the new instance.
So, as you can see, with this mechanism, you get rid of the switch logic.
Now, of course, your classes need to be registered with the factory. For that, in your factory add a method to register a class, by supplying the name or id of the class and a pointer to the creating function of the class (to keep it OO, this function can be a static function of your class). Like that, your objects can be registered in your factory, and be used anywhere in the code very easily.
The last point is really to register automatically these classes at the program start-up. To do that, you can use a little trick: define a static variable that is initialized by calling a function. This function will be responsible of registering your classes (static variables are evaluated before main gets called):
static int Var = RegisterMyClass();
The RegisterMyClass function will register the class in the factory.
So, in summary, what you have to provide when you want to add a new class: the class itself with a creation function (basically a simple new CMyClass), a function that will register the class (will simply call the Register of the factory and supply the class name and a pointer to the creation function) and a static variable that will only be used to register the class in the factory.
You can use a name to identify the class but you can also use an Id, it's up to you to decide what's the best option.
I hope this is clear. If not, don't hesitate to ask.
|
|
|
|
|
I know of no way to accomplish this in C++, without COM, GUIDs and the like, but that could get ugly real fast. I think you're stuck with writing a class factory (google that) of some kind.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi All
Infact I learned from the page
http://www.sysinternals.com/Informa...plications.html
that applications can be run while booting by using native appliocations, here having one problem is that how to build a native application.
So please guide me to build the native application, I have windows 200
Professional .
Please guide me.
Thanks.
|
|
|
|
|
any executable program can be run automatically while booting - not limited to "native app" (what does "native app" mean?).
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
It is an application that uses The Native API[^]. Win32 sits on top of a "Native API". Programs like "chkdsk" which run before the system has fully booted use this API. To a large degree Win32 is implemented in terms of this API so it is more fundamental. For example the Win32 function CreateFile is really a wrapper around the Native API NtCreateFile function.
Steve
|
|
|
|
|
I think you need the DDK to build native apps, but it's been a long time since I tinkered with that kind of thing.
Steve
|
|
|
|
|
This is the first time I write a program after learning C++ for 1 week ago.
I use Dev-C++ and I want my program to do function such as:
Ask person to type two number : 1st number ; 2nd number.
such as: 2 ; 5;
and I want my program to get me the sum : 2 + 3 + 4 + 5 = 14
but I try many times and it always gives me : 2 + 5 = 7
This is my code :
using namespace std;
#include <iostream>
long result(long d , long e)
{
if (d >= 1 , d < e)
{
return (result(d + 1,0));
}
else
return (0);
}
int main()
{
long a,b;
long c;
cout << "1st number : ";
cin >> a;
cout << "2nd number : ";
cin >> b;
c = a + result(a , b) + b;
cout << c;
return 0;
}
Can someone tell what 's wrong with my code, and give me a hint to do it.
Thankz.
|
|
|
|
|
simply write -
int main()
{
long a,b;
long c = 0;
cout << "1st number : ";
cin >> a;
cout << "2nd number : ";
cin >> b;
for (int i = a; i <= b; ++i)
c += i;
cout << c;
return 0;
}
your result() function is wrong which always returns zero.
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|