hi i developed this little code in asm, i have trouble converting it to c (I'm new at it)
here it is:
invoke lstrcat,addr PUrl,addr str1
invoke lstrcat,addr PUrl,addr str2
invoke lstrcat,addr PUrl,addr str3
invoke lstrcat,addr PUrl,addr str4
Invoke InternetOpen,addr GetUrl, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_NO_CACHE_WRITE
mov hHttpSession,eax
Invoke InternetOpenUrl,hHttpSession,addr PUrl, 0, 0,0,0
mov hUrl,eax
Invoke InternetCloseHandle,hUrl
Invoke InternetCloseHandle,hHttpSession
str1,str2 etc... are just null terminated strings.... anyone can translate this to c? thanks in advance
Tsongkie
here it is:
invoke lstrcat,addr PUrl,addr str1
invoke lstrcat,addr PUrl,addr str2
invoke lstrcat,addr PUrl,addr str3
invoke lstrcat,addr PUrl,addr str4
Invoke InternetOpen,addr GetUrl, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_NO_CACHE_WRITE
mov hHttpSession,eax
Invoke InternetOpenUrl,hHttpSession,addr PUrl, 0, 0,0,0
mov hUrl,eax
Invoke InternetCloseHandle,hUrl
Invoke InternetCloseHandle,hHttpSession
str1,str2 etc... are just null terminated strings.... anyone can translate this to c? thanks in advance
Tsongkie
A long time since I did any c but it should look something like this
lstrcat(PUrl,str1);
lstrcat(PUrl, str2);
lstrcat(PUrl, str3);
lstrcat(PUrl, str4);
hHttpSession=InternetOpen(GetUrl, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_NO_CACHE_WRITE);
hUrl=InternetOpenUrl(hHttpSession, PUrl, 0, 0,0,0);
InternetCloseHandle(hUrl);
InternetCloseHandle(hHttpSession);
lstrcat(PUrl,str1);
lstrcat(PUrl, str2);
lstrcat(PUrl, str3);
lstrcat(PUrl, str4);
hHttpSession=InternetOpen(GetUrl, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_NO_CACHE_WRITE);
hUrl=InternetOpenUrl(hHttpSession, PUrl, 0, 0,0,0);
InternetCloseHandle(hUrl);
InternetCloseHandle(hHttpSession);
Kudos,
you missed that a couple of the parameters are actually pointers, so i took the liberty of inserting them in your code. Note that i only looked at the code Tsongkie posted, i didn't check against MSDN to see if the calls and parameters were correct (<-- my disclaimer :) )
lstrcat(&PUrl,&str1);
lstrcat(&PUrl, &str2);
lstrcat(&PUrl, &str3);
lstrcat(&PUrl, &str4);
hHttpSession=InternetOpen(&GetUrl, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_NO_CACHE_WRITE);
hUrl=InternetOpenUrl(hHttpSession, &PUrl, 0, 0,0,0);
InternetCloseHandle(hUrl);
InternetCloseHandle(hHttpSession);
you missed that a couple of the parameters are actually pointers, so i took the liberty of inserting them in your code. Note that i only looked at the code Tsongkie posted, i didn't check against MSDN to see if the calls and parameters were correct (<-- my disclaimer :) )
lstrcat(&PUrl,&str1);
lstrcat(&PUrl, &str2);
lstrcat(&PUrl, &str3);
lstrcat(&PUrl, &str4);
hHttpSession=InternetOpen(&GetUrl, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_NO_CACHE_WRITE);
hUrl=InternetOpenUrl(hHttpSession, &PUrl, 0, 0,0,0);
InternetCloseHandle(hUrl);
InternetCloseHandle(hHttpSession);
Kudos' code was correct.
C passes arrays by reference automatically, and char arrays are no different. With the ampersand in there, C thinks you're giving it a reference to an array pointer, and you'll get an error, unless you do something like lstrcat( &PUrl[0], &str1[0] ); but that's just silly. ;)
In C an array is it's own data type. A pointer is a variable that holds an address, an array is the address. To illustrate:
char* myString1 = "??"; // legal operation
myString1[0] = '!'; // legal operation
myString1 = NULL; // legal operation
char myString2[] = "??"; // legal operation
myString2[0] = '!'; // legal operation
myString2 = NULL; // illegal operation
Edit: fixed code
C passes arrays by reference automatically, and char arrays are no different. With the ampersand in there, C thinks you're giving it a reference to an array pointer, and you'll get an error, unless you do something like lstrcat( &PUrl[0], &str1[0] ); but that's just silly. ;)
In C an array is it's own data type. A pointer is a variable that holds an address, an array is the address. To illustrate:
char* myString1 = "??"; // legal operation
myString1[0] = '!'; // legal operation
myString1 = NULL; // legal operation
char myString2[] = "??"; // legal operation
myString2[0] = '!'; // legal operation
myString2 = NULL; // illegal operation
Edit: fixed code
"]
anyone can translate this to c? thanks in advance
I'm sorry you go the wrong direction on one way street. :grin:
anyone can translate this to c? thanks in advance
Compiler goes C --> ASM, and your trying to swim up stream? :grin:
:tongue: Posted on 2002-05-06 17:18:19 by bitRAKE
I'm sorry you go the wrong direction on one way street. :grin:
Compiler goes C --> ASM, and your trying to swim up stream? :grin:
:tongue: Posted on 2002-05-06 21:19:13 by Tsongkie[ii]
got another problem
i'm using bc++ builder and memo1->text is not a valid char..... its a string.... how do i make it so that memo->text can be assigned to a char buffer?
i'm using bc++ builder and memo1->text is not a valid char..... its a string.... how do i make it so that memo->text can be assigned to a char buffer?
Tsongkie,
You'll need to be more clear when you ask questions. My advice is to pick up a good book on C programming or visit a C programming message board.
I think your last question has gone out of the scope of this forum. This message board is for Win32 assembly.
You'll need to be more clear when you ask questions. My advice is to pick up a good book on C programming or visit a C programming message board.
I think your last question has gone out of the scope of this forum. This message board is for Win32 assembly.
Kudos' code was correct. C passes arrays by reference automatically.....
Yeah, you are right :grin: Believe it or not, i have a nationally recognised qualification in C++ programming.... but it has been so long since i wrote some C, and i have done lots of work in VB, scripting languages, and ASM, that i have obviously forgotten some of the basics.... doh :rolleyes: