|
Howdy codies,
I'm getting a little bored with the plain old text editing in VS.Net for some of the code I have to edit (particularly makefiles), and I've been scouring MSDN for information on hwo to implement a new code editor, but to no avail.
Theres hints alluding to some secret SDK that VSIP (Visual Studio Intregration Partners), but no concrete information.
I als had a quick look at a .resx editor, which relied on the VSIPExtras package, but thats not publically available apparently.
So anyone know where to start for building a new code editor in VS.Net?
- Phil
|
|
|
|
|
I'm getting a value that represents my ip address in a long - 16951488. I can then ping that number and see my IP in network byte order - 1.2.168.192
Does anyone know of a function that will take the first long and convert it to an IP address?
Cheers,
Tom Archer - Archer Consulting Group
"So look up ahead at times to come, despair is not for us. We have a world and more to see, while this remains behind." - James N. Rowe
|
|
|
|
|
Cheesy solution, but should work. (Warning: untested!)
void convertLongToIpAddress
(long nLong,
unsigned char& ch0, <code>
unsigned char& ch1,
unsigned char& ch2,
unsigned char& ch3) <code>
{
ch0 = (unsigned char) (nLong & 0xFF000000) / (256 * 256 * 256);
ch1 = (unsigned char) (nLong & 0x00FF0000) / (256 * 256);
ch2 = (unsigned char) (nLong & 0x0000FF00) / 256);
ch3 = (unsigned char) nLong % 256;
} /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks Ravi, but this resulted in nothing in each of the char values.
|
|
|
|
|
It's an order of operations problem - put brackets around everything after the cast to unsigned char, the number is getting cast first, then divided.
I'd also replace the 256 divides with shifts.
void convertLongToIpAddress (long nLong,
unsigned char& ch0,
unsigned char& ch1,
unsigned char& ch2,
unsigned char& ch3) // lowest part
{
ch0 = (unsigned char) ((nLong & 0xFF000000) >> 24);
ch1 = (unsigned char) ((nLong & 0x00FF0000) >> 16);
ch2 = (unsigned char) ((nLong & 0x0000FF00) >> 8);
ch3 = (unsigned char) (nLong % 256);
}
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Why the '&' operation? The shifts cause the bits you need to be in the LS byte not? So the cast should truncate the other bits...
So the following code does the same in less CPU cycles:
void convertLongToIpAddress2 (long nLong,
unsigned char& ch0,
unsigned char& ch1,
unsigned char& ch2,
unsigned char& ch3)
{
ch0 = (unsigned char) (nLong >> 24);
ch1 = (unsigned char) (nLong >> 16);
ch2 = (unsigned char) (nLong >> 8);
ch3 = (unsigned char) (nLong);
}
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Yeah, this occured to me in the shower a half hour ago. Does that make me a total nerd ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Nah. I think that most developers are not nerds, even if they think about IT related stuff when they are taking a shower! Other people think about their work all the time. They even talk about it during dinner. I bet that most developers don't do that, since we know that nobody is going to understand what we will say about 95% of the time... So the real nerds (in terms of being obsessed with their work and talk about nothing else) is everybody else!
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Well, I thought of a faster way again on the way to work this morning...
void ConvertLongToIPAddress( long nLong,
unsigned char& ch0,
unsigned char& ch1,
unsigned char& ch2,
unsigned char& ch3) // lowest part
{
unsigned char * pIP = (unsigned char *) & nLong;
ch0 = pIP[3];
ch1 = pIP[2];
ch2 = pIP[1];
ch3 = pIP[0];
}
I seem to recall a Dilbert cartoon where he has to hand in a timesheet and says 'the time I spent doing nothing in meetings is marked as work, and the time I spent designing circuits in the shower is not on there'.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
Well, I thought of a faster way again on the way to work this morning...
LOL! Where do you get some rest?
I give up here. I might be able to prduce a slightly better result in assembly, but I want get back to something I left behind...
Christian Graus wrote:
I seem to recall a Dilbert cartoon where he has to hand in a timesheet and says 'the time I spent doing nothing in meetings is marked as work, and the time I spent designing circuits in the shower is not on there'.
I just love the Dilbert cartoons! Don't you?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
Where do you get some rest?
About five hours a night. Except when I have sticky programming problems, then I dream about them. Not that I'm obsessive or anything.
Bob Stanneveld wrote:
I just love the Dilbert cartoons! Don't you?
Yeah, they rule. NEver had a bad boss, so I can't relate, but I still love it. The books are even better, especially 'The Dilbert Future'. If you don't have it, get it. It's REALLY funny
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
Yeah, they rule. NEver had a bad boss, so I can't relate, but I still love it. The books are even better, especially 'The Dilbert Future'. If you don't have it, get it. It's REALLY funny
Í don't have it... yet!
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Not totally but close.
It used to be a running joke between me and my boss. I would always come up with my best ideas in the shower so one day after several instances of this he said, "you know, we should pay your water bill."
|
|
|
|
|
*grin* Now that would be nice. I often wake up with the answer to my programming questions, I wonder what bill i could give my boss in that instance ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
There's also:
in_addr ia;
ia.S_un.S_addr = 16951488;
TRACE(_T("%u.%u.%u.%u\n"),
ia.S_un.S_un_b.s_b4,
ia.S_un.S_un_b.s_b3,
ia.S_un.S_un_b.s_b2,
ia.S_un.S_un_b.s_b1);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
That's just what I was thinking. I had forgotten it was already built though.
|
|
|
|
|
I try to use EnumProcesses on Windows 2000/VC++6.0, but it need psapi.h & psapi.lib but they are wroking on windows NT?!!
|
|
|
|
|
Install the Platform SDK.
I don't think those two files came with the Visual Studio 6.0 distribution.
Make your Visual Studio development environment search into the platform SDK include and library folder ahead of the one delivered with Visul Studio 6.0.
|
|
|
|
|
Hello, i'm apoligize in advanced for this question, but all the explanations from the msdn, and such, that i got for it are extreamly confusing.
I would like to know what a Vector is and how i can use it.
thankz!
|
|
|
|
|
Which vector class are you talking about? For example the Standard Template Library provides an implementation of a vector class. The vector class can be used to store any number of elements of any type. For example you can have an array of integers but that is restricted to hold only as many items as you specify at the beginning as opposed to a vector in which you can store variable amount of data.
Here's some example code
<br />
std::vector<int> BunchOfNumbers;<br />
BunchOfNumbers.push_back(1);<br />
BunchOfNumbers.push_back(32);<br />
<br />
for (int j = 0; j < BunchOfNumbers.size(); j++)<br />
{<br />
printf("%d", BunchOfNumbers[j]);<br />
}<br />
|
|
|
|
|
A vector is a form of array. Its can be added to on the fly and grows as needed, managing the memory allocation as you go. You can also access it like an array. Its there to make life easiser.
e.g.
#include <vector>
using namespace std;
void main()
{
vector<int> a;
int i = 2;
a.push_back(5 * i);
a.push_back(3 * i);
printf("size is [%d], first is [%d], second is [%d]", a.size(), a[0], a[1]\n");
}
Outputs:
"Size is 2, first is 10, second is 6
There is more you can do, but you can find that out yourself.
|
|
|
|
|
To add to the other explanations - what makes vector cool is that it shares a common interface with other container classes through a thing called an iterator. While you can use array notation to access a vectors members, you can use iterators to step through them also, and the STL contains a lot of algorithms that take iterators and work on containers to organise and process their contents.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Whooop! Looks like they forgot to preview.
Variable array of intergers:
std::vector<int> int_array;
Most used methods:
back(): returns a reference to the last element.
pop_back(): remove the last element.
operator[]: returns a refernce a specific element.
push_back(element): adds an element to the end of array.
begin(): returns iterator of first element.
end(): returns interactor just passed the last element.
capacity(): the number of elements it can hold before it has to reallocate storage.
size(): the number of elements currently stored.
erase(...): removes 1 or more elements from array.
clear(): removes all elements from array.
empty(): (size() < 1)
reserve(n): reserves extra storage space (capacity); if you know approximately how many elements you need to store, then reserving that amount will reduce the number of reallocations required (thus increasing the speed of insertion and reducing memory fragmentaion).
typedef std::vector<int> int_array_type;
int_array_type int_array;
for( int i=0; i<int_array.size(); ++i )
{
if( some_int_value == int_array[i] )
}
int_array_type::const_iterator i = int_array.begin();
for( ; i != int_array.end(); ++i )
{
if( some_int_value == *i )
}
Hope that helps.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I have a CList containing objects. I want to know if I can use a vector on this CLIst or do I have to use vector<myojb> instead of CList.
The issue here is that I need a container that I can easily add/remove objects to, test to see if its empty and sometimes apply a function to that object.
This is my first time thinking of using vectors, but I like the for_each option instead of using a 'typical' for loop using CList.GetNext(pos).
ANy ideas?
|
|
|
|