|
ooops, sory, i didn't see either it was a CString... (and i didn't see David's posts 'cause i was writing mine).
well, by passing it to the function, just cast it before with the (LPCTSTR) operator defined in CString.
TOXCCT >>> GEII power
|
|
|
|
|
maybe a standard fonction does this (inet_addr() i think, but i don't remember), the folowing works fine, even if it can seem "heavy" :
<font style="color:blue;">#include</font> <stdlib.h> <font style="color:green;">
<font style="color:blue;">#include</font> <ctype.h> <font style="color:green;">
<font style="color:blue;">#include</font> <string.h> <font style="color:green;">
<font style="color:blue;">enum </font>IPValidate {
IP_ERR = 0,
IP_OK = 1
};
<font style="color:blue;">int</font> str2bytesIPAddr (<font style="color:blue;">char </font>pcDestTab[], <font style="color:blue;">const char</font>* pcIPAddr) {
<font style="color:green;">
</font>
<font style="color:blue;">int </font>iCptCharIntoIPAddr = 0;
<font style="color:blue;">int </font>iCptCharIntoByte = 0;
<font style="color:blue;">int </font>iResult = IP_OK;
<font style="color:blue;">short </font>sNbBytes = 0;
<font style="color:blue;">char </font>pstrByte[16];<font style="color:green;">
</font>
<font style="color:blue;">if </font>(strlen(pcIPAddr) > 15) {<font style="color:green;">
</font> iResult = IP_ERR;
}
<font style="color:blue;">else </font>{
<font style="color:blue;">do </font>{
<font style="color:blue;">if </font>(isdigit(pcIPAddr[iCptCharIntoIPAddr])) {
<font style="color:green;">
<font style="color:blue;">if </font>((iCptCharIntoByte == 0) && (pcIPAddr[iCptCharIntoIPAddr] == '0') && (isdigit(pcIPAddr[iCptCharIntoIPAddr+1]))) {
iResult = IP_ERR;
}
<font style="color:blue;">else </font>{
pstrByte[iCptCharIntoByte] = pcIPAddr[iCptCharIntoIPAddr];
iCptCharIntoIPAddr++;
iCptCharIntoByte++;
}
}
<font style="color:blue;">else </font>{
<font style="color:blue;">if </font>(pcIPAddr[iCptCharIntoIPAddr] == '.') {
<font style="color:green;">
</font>
pstrByte[iCptCharIntoByte] = '\0';
iCptCharIntoByte = 0;
iCptCharIntoIPAddr++;
pcDestTab[sNbBytes] = atoi(pstrByte);
sNbBytes++;
<font style="color:blue;">if </font>((atoi(pstrByte) > 255) || (atoi(pstrByte) < 0)) {
<font style="color:green;">
iResult = IP_ERR;
}
}
<font style="color:blue;">else </font>{
<font style="color:green;">
iResult = IP_ERR;
}
}
} <font style="color:blue;">while </font>((pcIPAddr[iCptCharIntoIPAddr] != '\0') && (sNbBytes <= 3) && (iResult == IP_OK));
<font style="color:blue;">if </font>((pcIPAddr[iCptCharIntoIPAddr] == '\0') && (sNbBytes <= 3) && (iResult == IP_OK)) {
pstrByte[iCptCharIntoByte] = '\0';
pcDestTab[sNbBytes] = atoi(pstrByte);
sNbBytes++;
<font style="color:blue;">if </font>((atoi(pstrByte) > 255) || (atoi(pstrByte) < 0)) {
iResult = IP_ERR;
}
}
<font style="color:green;">
</font>
<font style="color:blue;">if </font>(sNbBytes != 4) {
iResult = IP_ERR;
}
}
<font style="color:blue;">return </font>iResult;
}
TOXCCT >>> GEII power
|
|
|
|
|
cheers guys
tis working
struct in_addr ia;
ia.s_addr = inet_addr(strAdapterInfo);
BYTE localIp[3];
localIp[0] = ia.S_un.S_un_b.s_b1;
localIp[1] = ia.S_un.S_un_b.s_b2;
localIp[2] = ia.S_un.S_un_b.s_b3;
localIp[3] = ia.S_un.S_un_b.s_b4;
Thanks again
|
|
|
|
|
i forgot to say (if it was interresting you) that it was previously a isIPAddr() that i added two lines (twice the following : pcDestTab[sNbBytes] = atoi(pstrByte); ).
i hope that can be helpful to understand the way an IP Address is analysed, and so on.
TOXCCT >>> GEII power
|
|
|
|
|
Hi
I Hope this will work
1.
CString str = "127,0,0,1";
int length = str .GetLength();
BYTE localIp[length] ;
memcpy(localIp,str,length);
or do it
for(int i = 0;i
|
|
|
|
|
ah ah ahh,
do you just know what is an IP ?
what you are suggesting will do so : ['1', '2', '7', '.', '0', '.', '.', '1']
that's not what we want.
a coded IP Address is coded on 4 bytes, which represent each blocks of values.
it will be either : [0x7F, 0x00, 0x00, 0x01].
TOXCCT >>> GEII power
|
|
|
|
|
Hi
I want to initialize this struct
struct CATEGORY_CODES
{
CString strCategoryCode;
int nCategoryID;
CString strCategoryName;
int nHasSubCategory;
int nActive;
};
if i do CATEGORY_CODE stCatCode = {0};
I get the Fatal error on CString members if i try to insert the values init.
Can anybody help me how to intialize the structures in MFC
thanks
shailesh
|
|
|
|
|
it is not an MFC problem, it is a simple C rule !
if you write {0} , the compiler wont accept for such strusture because it doesn't contain only one member (an such member cannot be stored with a 0 ).
you have two possibilities :
first one :
<font style="color:purple;">CATEGORY_CODE </font>stCatCode = {
<font style="color:gray;">""</font>,
0,
<font style="color:gray;">""</font>,
0,
0
}; <font style="color:green;">
with a GNU compiler, you could also write :
<font style="color:purple;">CATEGORY_CODE </font>stCatCode = {
strCategoryCode: <font style="color:gray;">""</font>,
nCategoryID: 0,
strCategoryName: <font style="color:gray;">""</font>,
nHasSubCategory: 0,
nActive: 0
};
second one :
<font style="color:purple;">CATEGORY_CODE </font>stCatCode;
stCatCode.strCategoryCode = <font style="color:gray;">""</font>;
stCatCode.nCategoryID = 0;
stCatCode.strCategoryName = <font style="color:gray;">""</font>;
stCatCode.nHasSubCategory = 0;
stCatCode.nActive = 0;
is that ok for you ?
TOXCCT >>> GEII power
|
|
|
|
|
Give it a constructor that initializes the variables.
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
I am attempting to save data to a MatLab .mat file from Visual C++. I know how to use matPutVariable to do this in the standard way, but I would like to be able to save this data incrementally without allocating the full mxArray, because the size of the array would be so large as to cause a memory shortage.
Analogously, if I were writing this data to a text file, I would open the text file in append mode and print each datum to the end of the file as it's calculated. Is there a way to do this when saving to a .mat file?
|
|
|
|
|
Hello gurus
well actually i am looking for a data structure or something like that for fast access to data. Actually my problem is that i have this image file dimensions size is 200 X 200 and what actually i want to do with the image is extract exhaustively 20X20 parts and make some calcualtions on that window from the image and store them. At present i am storing each 20X20 window in a vector object actually this takes a lot time when i want to retrieve the window and make calculations is there some way i can store this 20X20 window somewhere in the memory my point is fast access where i retrieve the values please help
Regards
Ahmed Ajmal
|
|
|
|
|
I need to create a console app or service to run on win98/ME or even 95.
I need to check a directory for the drop of a request file.
The request needs to be packaged for sending to a service on a remote server.It is a web server running jsp etc.
C/C++ needs to send request to either an existing instance of IE or invoke a new instance if one doesn't exist to forward the request.
This sends the request to the web server and the explorer says waiting. When response comes back the browser is used to react to the response etc.
However Visual C program job is essentially over once the browser is invoked (except it continues to check the directory for next request etc)
I am assuming that I need to populate hidden fields on the page and invoke a call to the server.
I have looked at ShellExec and CreateProcess etc. And I am just getting more and more confused.
Can anyone point me in the direction of any reference that can help me with this.
Creating a service on a non NT/XP/2000 machine is my next task as I don't think win9x has a service manager. But that is another story.
Any help would be much appreciated
|
|
|
|
|
use UrlDownloadToFile()
with query strings.
like http://myserver/mypage.jsp?val1=10&val2=surya
by this you can save the result also.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Thanks
Is there a way that I could get a handle to the browser window from fist call and invoke the same http://myserver/mypage.jsp?val1=10&val2=surya with submit over and over after viewing results.
It is being driven by a file being dropped onto client and the values taken from that file - every time a file is dropped the browser is invoked and the result is displayed.
I haven't tried this UrlDownloadtoFile yet but what I really need is somethinkg like a ShellExec using http://myserver/mypage.jsp?val1=10&val2=surya&submit=Submit that re-uses the same browser - at moment it opens a brand new browser.
Would I have to search for any open browser windows with the specified title and use that - or is there a mathod that keeps a handle to that browser window.
It is also being fired from a service or console app.
|
|
|
|
|
Hi all;
I have downloaded Skin Magic in order to build custom skins for my application. Everything works fine and i have exported the .h file associated with my skin. The problem is now, "how will i include the skin in my application?".
Can somebody please help, i'm pretty at lost with this issue.
Thanks
Krugger
|
|
|
|
|
If you go through the samples that they have provided, then you will have some idea how to use them.
God is Real, unless declared Integer.
|
|
|
|
|
Hi all;
I am developing an SDI application which consists of a CDialogBar. On the bar, i have a tree control displaying some data. I also have a webbrowser control in the View. I need to display an HTML page in the webbrowser control according to the selected tree child clicked by the user. Can somebody, please help me, to access the webbrowser control from my TreeControl.
Thank you
Krugger
|
|
|
|
|
Hi all;
I am currently buidling an SDI application. This application has a CDialogBar (well, some sort of. The actual class used is derived from CDialogBar). The problem is that i have some list_controls which need to be updated and i need the dialog handle. Since the CDialogBar is modeless, the handle is lost and i get an "enormous" assertion error each time i try to add or remove items to the list_control. Can somebody please help me on this.
I badly need it.
Thank you
Krugger
|
|
|
|
|
datastruct wrote:
CDialogBar is modeless, the handle is lost and i get an "enormous" assertion error
if you want it you should save it.
God is Real, unless declared Integer.
|
|
|
|
|
Does anyone know where I could get a free program that intercepts Winsock Messages on a specific port, and displays the message for debugging programs? Thanks a bunch....
-KMaz
|
|
|
|
|
google on ethereal
TOXCCT >>> GEII power
|
|
|
|
|
ethereal is a freeware, 10Mo heavy...
TOXCCT >>> GEII power
|
|
|
|
|
cant say for sure, but try running "netstat" from the command-promt in a seperate window when u run ur program.
Well, netstat gives list and condition of all active connections and at-times becomes very messy, but try it if u dont find anything else.
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
I have a common C++ program and try to execute DoModal() on my dialog. When I do it from within the view it goes well but when i do it from another dialog that is a child to the view the dialog doesn't get focus even though i click in it. When I click on my program down in the program bar, the dialog gets focus. Anybody had this problem?
Robert
|
|
|
|
|
yes it does. just take care off the return value of OnInitDialog()
TOXCCT >>> GEII power
|
|
|
|