www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - setting IE options

reply Tyro[a.c.edwards] <no spam.com> writes:
I'm looking for some guidance on how to Internet Explorer options using
functionality available in D. I am trying to make the following work but cannot
since I don't have a copy of wininet.lib:

import std.c.windows.windows;
extern(Windows){
alias HANDLE HINTERNET;
	
struct INTERNET_PER_CONN_OPTION {
	DWORD dwOption;
	//union Value {    DWORD dwValue;    LPTSTR pszValue;    FILETIME ftValue;  }
; // Does not work
	union {    DWORD dwValue;    LPTSTR pszValue;    FILETIME ftValue;  } ; //
hopefully that does the trick
}
alias INTERNET_PER_CONN_OPTION* LPINTERNET_PER_CONN_OPTION;

struct INTERNET_PER_CONN_OPTION_LIST {
	DWORD dwSize;
	LPTSTR pszConnection;
	DWORD dwOptionCount;
	DWORD dwOptionError;
	LPINTERNET_PER_CONN_OPTION pOptions;
}
alias INTERNET_PER_CONN_OPTION_LIST* LPINTERNET_PER_CONN_OPTION_LIST;

enum {
	INTERNET_PER_CONN_PROXY_SERVER = 2,
	INTERNET_OPTION_PER_CONNECTION_OPTION = 75
}

bool InternetSetOption(
	HINTERNET hInternet,
	DWORD dwOption,
	LPVOID lpBuffer,
	DWORD dwBufferLength
);
}

int main(char[][] args) 
{ 
INTERNET_PER_CONN_OPTION_LIST    List;
INTERNET_PER_CONN_OPTION         Option[1];
ulong                            nSize = INTERNET_PER_CONN_OPTION_LIST.sizeof;

Option[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
//Option[0].Value.pszValue = "http://myproxy:8080";
Option[0].pszValue = "http://myproxy:8080"; // Is that even legal?


List.dwSize = INTERNET_PER_CONN_OPTION_LIST.sizeof;
List.pszConnection = null;
List.dwOptionCount = 1;
List.dwOptionError = 0;
List.pOptions = &Option[0];

if(!InternetSetOption(null, INTERNET_OPTION_PER_CONNECTION_OPTION, &List,
nSize))
   printf("InternetQueryOption failed! (%d)\n", GetLastError()); 

return 0; 

}

Thanks,
Andrew
Dec 04 2007
parent reply Tyro[a.c.edwards] <no spam.com> writes:
Tyro[a.c.edwards] Wrote:

 I'm looking for some guidance on how to Internet Explorer options using
functionality available in D. I am trying to make the following work but cannot
since I don't have a copy of wininet.lib:
I located wininet.dll and build from it a .lib file using implib. However when attempting to compile the program the following error occurs: Error 42: Symbol Undefined _InternetSetOption --- errorlevel 1 Is there something I am missing? Any advice is appreciated.
 import std.c.windows.windows;
 extern(Windows){
 alias HANDLE HINTERNET;
 	
 struct INTERNET_PER_CONN_OPTION {
 	DWORD dwOption;
 	//union Value {    DWORD dwValue;    LPTSTR pszValue;    FILETIME ftValue;  }
; // Does not work
 	union {    DWORD dwValue;    LPTSTR pszValue;    FILETIME ftValue;  } ; //
hopefully that does the trick
 }
 alias INTERNET_PER_CONN_OPTION* LPINTERNET_PER_CONN_OPTION;
 
 struct INTERNET_PER_CONN_OPTION_LIST {
 	DWORD dwSize;
 	LPTSTR pszConnection;
 	DWORD dwOptionCount;
 	DWORD dwOptionError;
 	LPINTERNET_PER_CONN_OPTION pOptions;
 }
 alias INTERNET_PER_CONN_OPTION_LIST* LPINTERNET_PER_CONN_OPTION_LIST;
 
 enum {
 	INTERNET_PER_CONN_PROXY_SERVER = 2,
 	INTERNET_OPTION_PER_CONNECTION_OPTION = 75
 }
 
 bool InternetSetOption(
 	HINTERNET hInternet,
 	DWORD dwOption,
 	LPVOID lpBuffer,
 	DWORD dwBufferLength
 );
 }
 
 int main(char[][] args) 
 { 
 INTERNET_PER_CONN_OPTION_LIST    List;
 INTERNET_PER_CONN_OPTION         Option[1];
 ulong                            nSize = INTERNET_PER_CONN_OPTION_LIST.sizeof;
 
 Option[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
 //Option[0].Value.pszValue = "http://myproxy:8080";
 Option[0].pszValue = "http://myproxy:8080"; // Is that even legal?
 
 
 List.dwSize = INTERNET_PER_CONN_OPTION_LIST.sizeof;
 List.pszConnection = null;
 List.dwOptionCount = 1;
 List.dwOptionError = 0;
 List.pOptions = &Option[0];
 
 if(!InternetSetOption(null, INTERNET_OPTION_PER_CONNECTION_OPTION, &List,
nSize))
    printf("InternetQueryOption failed! (%d)\n", GetLastError()); 
 
 return 0; 
 
 }
 
 Thanks,
 Andrew
Dec 05 2007
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Tyro[a.c.edwards] wrote:
 Tyro[a.c.edwards] Wrote:
 
 I'm looking for some guidance on how to Internet Explorer options using
functionality available in D. I am trying to make the following work but cannot
since I don't have a copy of wininet.lib:
I located wininet.dll and build from it a .lib file using implib. However when attempting to compile the program the following error occurs: Error 42: Symbol Undefined _InternetSetOption --- errorlevel 1 Is there something I am missing? Any advice is appreciated.
You need to use the /system flag with implib. f:\usr\pkg\d>implib /h Digital Mars Import Library Manager Version 7.6B1n Copyright (C) Digital Mars 2000. All Rights Reserved. Usage: IMPLIB [switches] implibname.lib [ file.dll | file.def ] switches: /? Print this message /b Batch /h Print this message /i Ignore case of symbols /noi Be case sensitive. Mark library as case sensitive /nowep Ignore WEP /p:number Set page size to number (a power of 2) /system Prepend '_' to exported internal names (NT system DLL) ---bb
Dec 05 2007
parent reply Tyro[a.c.edwards] <no spam.com> writes:
Bill Baxter Wrote:

 Tyro[a.c.edwards] wrote:
 Tyro[a.c.edwards] Wrote:
 
 I'm looking for some guidance on how to Internet Explorer options using
functionality available in D. I am trying to make the following work but cannot
since I don't have a copy of wininet.lib:
I located wininet.dll and build from it a .lib file using implib. However when attempting to compile the program the following error occurs: Error 42: Symbol Undefined _InternetSetOption --- errorlevel 1 Is there something I am missing? Any advice is appreciated.
You need to use the /system flag with implib. f:\usr\pkg\d>implib /h Digital Mars Import Library Manager Version 7.6B1n Copyright (C) Digital Mars 2000. All Rights Reserved. Usage: IMPLIB [switches] implibname.lib [ file.dll | file.def ] switches: /? Print this message /b Batch /h Print this message /i Ignore case of symbols /noi Be case sensitive. Mark library as case sensitive /nowep Ignore WEP /p:number Set page size to number (a power of 2) /system Prepend '_' to exported internal names (NT system DLL) ---bb
Thanks, I have tried both /i, /noi, /system, combinations, and now switch. However, no attempt thus far has produced the desired result.
Dec 05 2007
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Tyro[a.c.edwards] wrote:
 Bill Baxter Wrote:
 
 Tyro[a.c.edwards] wrote:
 Tyro[a.c.edwards] Wrote:

 I'm looking for some guidance on how to Internet Explorer options using
functionality available in D. I am trying to make the following work but cannot
since I don't have a copy of wininet.lib:
I located wininet.dll and build from it a .lib file using implib. However when attempting to compile the program the following error occurs: Error 42: Symbol Undefined _InternetSetOption --- errorlevel 1 Is there something I am missing? Any advice is appreciated.
You need to use the /system flag with implib. f:\usr\pkg\d>implib /h Digital Mars Import Library Manager Version 7.6B1n Copyright (C) Digital Mars 2000. All Rights Reserved. Usage: IMPLIB [switches] implibname.lib [ file.dll | file.def ] switches: /? Print this message /b Batch /h Print this message /i Ignore case of symbols /noi Be case sensitive. Mark library as case sensitive /nowep Ignore WEP /p:number Set page size to number (a power of 2) /system Prepend '_' to exported internal names (NT system DLL) ---bb
Thanks, I have tried both /i, /noi, /system, combinations, and now switch. However, no attempt thus far has produced the desired result.
Ah, ok. Check dependency walker or dumbpin /exports. There is no InternetSetOption function. Only these: InternetSetOptionA InternetSetOptionExA InternetSetOptionExW InternetSetOptionW You need to choose either the A or W version depending on what text encoding you're using. --bb
Dec 05 2007
parent reply Tyro[a.c.edwards] <no smap.com> writes:
Bill Baxter Wrote:

 Tyro[a.c.edwards] wrote:
 Bill Baxter Wrote:
 
 Tyro[a.c.edwards] wrote:
 Tyro[a.c.edwards] Wrote:

 I'm looking for some guidance on how to Internet Explorer options using
functionality available in D. I am trying to make the following work but cannot
since I don't have a copy of wininet.lib:
I located wininet.dll and build from it a .lib file using implib. However when attempting to compile the program the following error occurs: Error 42: Symbol Undefined _InternetSetOption --- errorlevel 1 Is there something I am missing? Any advice is appreciated.
You need to use the /system flag with implib. f:\usr\pkg\d>implib /h Digital Mars Import Library Manager Version 7.6B1n Copyright (C) Digital Mars 2000. All Rights Reserved. Usage: IMPLIB [switches] implibname.lib [ file.dll | file.def ] switches: /? Print this message /b Batch /h Print this message /i Ignore case of symbols /noi Be case sensitive. Mark library as case sensitive /nowep Ignore WEP /p:number Set page size to number (a power of 2) /system Prepend '_' to exported internal names (NT system DLL) ---bb
Thanks, I have tried both /i, /noi, /system, combinations, and now switch. However, no attempt thus far has produced the desired result.
Ah, ok. Check dependency walker or dumbpin /exports. There is no InternetSetOption function. Only these: InternetSetOptionA InternetSetOptionExA InternetSetOptionExW InternetSetOptionW You need to choose either the A or W version depending on what text encoding you're using. --bb
Unfortunately, that doesn't work either. I've used both options and gotten the same result. Again thanks for the assistance.
Dec 05 2007
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Tyro[a.c.edwards] wrote:
 Bill Baxter Wrote:
 
 Tyro[a.c.edwards] wrote:
 Bill Baxter Wrote:

 Tyro[a.c.edwards] wrote:
 Tyro[a.c.edwards] Wrote:

 I'm looking for some guidance on how to Internet Explorer options using
functionality available in D. I am trying to make the following work but cannot
since I don't have a copy of wininet.lib:
I located wininet.dll and build from it a .lib file using implib. However when attempting to compile the program the following error occurs: Error 42: Symbol Undefined _InternetSetOption --- errorlevel 1 Is there something I am missing? Any advice is appreciated.
You need to use the /system flag with implib. f:\usr\pkg\d>implib /h Digital Mars Import Library Manager Version 7.6B1n Copyright (C) Digital Mars 2000. All Rights Reserved. Usage: IMPLIB [switches] implibname.lib [ file.dll | file.def ] switches: /? Print this message /b Batch /h Print this message /i Ignore case of symbols /noi Be case sensitive. Mark library as case sensitive /nowep Ignore WEP /p:number Set page size to number (a power of 2) /system Prepend '_' to exported internal names (NT system DLL) ---bb
Thanks, I have tried both /i, /noi, /system, combinations, and now switch. However, no attempt thus far has produced the desired result.
Ah, ok. Check dependency walker or dumbpin /exports. There is no InternetSetOption function. Only these: InternetSetOptionA InternetSetOptionExA InternetSetOptionExW InternetSetOptionW You need to choose either the A or W version depending on what text encoding you're using. --bb
Unfortunately, that doesn't work either. I've used both options and gotten the same result. Again thanks for the assistance.
Did you use extern(Windows) or extern(System) when you declared the prototype for D to call? --bb
Dec 05 2007
parent Tyro[a.c.edwards] <no smap.com> writes:
Bill Baxter Wrote:

 Tyro[a.c.edwards] wrote:
 Bill Baxter Wrote:
 
 Tyro[a.c.edwards] wrote:
 Bill Baxter Wrote:

 Tyro[a.c.edwards] wrote:
 Tyro[a.c.edwards] Wrote:

 I'm looking for some guidance on how to Internet Explorer options using
functionality available in D. I am trying to make the following work but cannot
since I don't have a copy of wininet.lib:
I located wininet.dll and build from it a .lib file using implib. However when attempting to compile the program the following error occurs: Error 42: Symbol Undefined _InternetSetOption --- errorlevel 1 Is there something I am missing? Any advice is appreciated.
You need to use the /system flag with implib. f:\usr\pkg\d>implib /h Digital Mars Import Library Manager Version 7.6B1n Copyright (C) Digital Mars 2000. All Rights Reserved. Usage: IMPLIB [switches] implibname.lib [ file.dll | file.def ] switches: /? Print this message /b Batch /h Print this message /i Ignore case of symbols /noi Be case sensitive. Mark library as case sensitive /nowep Ignore WEP /p:number Set page size to number (a power of 2) /system Prepend '_' to exported internal names (NT system DLL) ---bb
Thanks, I have tried both /i, /noi, /system, combinations, and now switch. However, no attempt thus far has produced the desired result.
Ah, ok. Check dependency walker or dumbpin /exports. There is no InternetSetOption function. Only these: InternetSetOptionA InternetSetOptionExA InternetSetOptionExW InternetSetOptionW You need to choose either the A or W version depending on what text encoding you're using. --bb
Unfortunately, that doesn't work either. I've used both options and gotten the same result. Again thanks for the assistance.
Did you use extern(Windows) or extern(System) when you declared the prototype for D to call? --bb
Initially I used extern(Windows) but I just tried extern(System) and got the same result.
Dec 05 2007