|
오늘 |
전체 |
|
| 방문자 |
4 |
27358 |
|
| 구독자 |
0 |
0 |
|
| 댓글 |
0 |
2 |
|
| 참조글 |
0 |
0 |
|
|
|
|
1
|
2
|
3
|
4
|
5
|
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
|
13
|
14
|
15
|
16
|
17
|
18
|
19
|
|
20
|
21
|
22
|
23
|
24
|
25
|
26
|
|
27
|
28
|
29
|
30
|
31
|
|
|
|
|
|
|
|
|
|
|
솔직히 말씀 드려서 win32 로 브라우저를 만들 생각은 아예 안 해 봤습니다.
가능 하겠지만 어려워서.... 일단 화면에 보이기는 쉬습니다 그러나 이것들을
control 할려면 복잡할 겁니다. 여기 저기에서 뛰어나오는 인터페이스들과
이것들을 이용하고 해체하고.....
MFC 로 html 다루는 것을 싫어 합니다. 대신 ATL 을 쓰지요...
atl 로 webbrowser 를 구현한 것이 있는데... mfc 의 chtmlview 보다
훨씬 기능도 많고 뛰어 납니다.
http://msdn.microsoft.com/downloads/samples/Internet/browser/atlbrowser/Default.asp
Internet 함수들이란?
(with easy access to standard Internet protocols such as Gopher, FTP, and HTTP)
Microsoft Win32 Internet Functions Reference
(자세한것은 http://msdn.microsoft.com/workshop/networking/wininet/overview/overview.asp)
* General Win32 Internet Functions - basic Internet file manipulations.
* Automatic Dialing Functions - this section handle dial-up access to the
Internet.
* Uniform Resource Locator (URL) Functions
* FTP Functions
* Gopher Functions
* HTTP Functions
- The HTTP functions described in this section control the transmission
and content of HTTP requests.
* Cookie Functions - Cookie
* Persistent URL Cache Functions - Cache
IWebBrowser 는 위 Internet API 보다 보다 낮은 수준에서 접근할수 있다는점이
차이점 아닐까요.... 솔직히 많이 사용해 봤지만 차이점을 염두해 두지 않아서...
[질문 내용]***********************************************
올린이 : 이정배
안녕하세요. 새내기 정배라고 합니다 ^^;
제가 Win32API로 프로그래밍하고 있는데요.
대화상자에 웹을 띄울려고 하거든요.
혹시 API로 이런걸 해보신 분 있으신지..
그중에서 Internet API 나 IWebBrowser2 를 써보신 분들은
소스를 좀 부탁드립니다~.
MSDN엔 샘플소스가 없더라고요..
코드만으로는 거의 모르겠구요.
또 저 둘의 차이점이나 개요등을 아시면 조금의 설명도 부탁드리겠습니다~.
이걸로 아마 API상에서 대화상자에 웹을 띄울수 있을꺼 같거든요.
API로 ActiveX를 사용하려니까 좀 어려운거 같아서 --;;
요즘 제가 이 문제땜에 아주 골머리를 T_T... 흑흑
|
http://kr.blog.yahoo.com/jhanglim/trackback/13/93
|
|
|
|
|
|
|
|
|
|
InternetSetCookie Function
InternetGetCookie Function
|
http://kr.blog.yahoo.com/jhanglim/trackback/13/92
|
|
|
|
|
|
|
|
|
|
Managing Cookies
--------------------------------------------------------------------------------
Under HTTP protocol, a server or a script uses cookies to maintain state information on the client workstation. The Win32® Internet functions have implemented a persistent cookie database for this purpose. The Win32 Internet cookie functions are used to set cookies into and access cookies from the cookie database. For more information on HTTP cookies, see HTTP Cookies.
The Win32 Internet functions InternetSetCookie and InternetGetCookie can be used to manage cookies. Note that the implementation of these functions is evolving; be cautious when using them.
Using Cookie Functions
The following functions allow an application to create or retrieve cookies in the cookie database.
InternetGetCookie Retrieves cookies for the specified URL and all its parent URLs.
InternetSetCookie Sets a cookie on the specified URL.
Unlike most of the Win32 Internet functions, the cookie functions do not require a call to InternetOpen. Cookies that have an expiration date are stored in the windows\cookies directory. Cookies that don't have an expiration date are stored in memory and are available only to the process in which they were created.
Getting a Cookie
InternetGetCookie returns the cookies for the specified URL and all its parent URLs.
The following example demonstrates a call to InternetGetCookie.
char szURL[256]; // buffer to hold the URL
LPSTR lpszData = NULL; // buffer to hold the cookie data
DWORD dwSize=0; // variable to get the buffer size needed
// Insert code to retrieve the URL.
retry:
// The first call to InternetGetCookie will get the required
// buffer size needed to download the cookie data.
if (!InternetGetCookie(szURL, NULL, lpszData, &dwSize))
{
// Check for an insufficient buffer error.
if (GetLastError()== ERROR_INSUFFICIENT_BUFFER)
{
// Allocate the necessary buffer.
lpszData = new char[dwSize];
// Try the call again.
goto retry;
}
else
{
// Insert error handling code.
}
}
else
{
// Insert code to display the cookie data.
// Release the memory allocated for the buffer.
delete[]lpszData;
}
Setting a Cookie
InternetSetCookie is used to set a cookie on the specified URL. InternetSetCookie can create both persistent and session cookies.
Persistent cookies are cookies that have an expiration date. These cookies are stored in the windows\system directory.
Session cookies are stored in memory and can be accessed only by the process that created them.
The data for the cookie should be in the format:
NAME=VALUE
For the expiration date, the format must be:
DAY, DD-MMM-YYYY HH:MM:SS GMT
DAY is the three-letter abbreviation for the day of the week, DD is the day of the month, MMM is the three-letter abbreviation for the month, YYYY is the year, and HH:MM:SS is the time of the day in military time.
The following example demonstrates two calls to InternetSetCookie. The first call creates a session cookie and the second creates a persistent cookie.
BOOL bReturn;
// Create a session cookie.
bReturn = InternetSetCookie("http://www.adventure_works.com", NULL,
"TestData = Test");
// Create a persistent cookie.
bReturn = InternetSetCookie("http://www.adventure_works.com", NULL,
"TestData = Test; expires = Sat, 01-Jan-2000 00:00:00 GMT");
|
http://kr.blog.yahoo.com/jhanglim/trackback/13/91
|
|
|
|
|
|
|
|
|
http://kr.blog.yahoo.com/jhanglim/trackback/13/90
|
|
|
|
|
|
|
|
|
|
순수하게 win32 만으로 할려니까... 어렵네요...
간단하게 atl 로 dialog 에 web browser 띄우는 것을 해 보겠습니다.
차례대로 따라 하세요.
1. AtlCom Object Wizard 로 들어갑니다. (이름을 마음대로 만드세요)
2. type 은 DLL, (실행, 서비스)EXE 가 있는데... 실행 EXE 하세요.
3. 프로젝트가 생성 되었고, Menu/insert/New ATL Object 를 선택하시면
3번째 분류에 Dialog 라는 것이 있습니다.
short name 만 지정하시고 만듭니다.
4. 다이얼로그가 생성되는데 여기다가 오른쪽 클릭후 Insert ActiveX 에서
Microsoft 웹 브라우저를 선택해서 추가합니다. 적당하게 Dlg 를 눌려주세요
5. 다이얼로그의 OnInitDialog()를 다음과 같이고치세요.
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
HRESULT hr;
CComPtr< IWebBrowser2> spIE;
m_IEHost = GetDlgItem(IDC_EXPLORER1);
hr = m_IEHost.QueryControl(IID_IWebBrowser2,(PVOID *)&spIE);
hr = spIE->put_Visible(VARIANT_TRUE);
hr = spIE->GoHome();
return 1; // Let the system set the focus
}
6. CAxWindow m_IEHost; 를 .h 에 추가하세요.
7. _tWinMain 부분을 다음과 같이 고치세요.
if (bRun)
{
_Module.StartMonitor();
#if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);
_ASSERTE(SUCCEEDED(hRes));
hRes = CoResumeClassObjects();
#else
hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE);
#endif
_ASSERTE(SUCCEEDED(hRes));
C????Dlg dlg;
dlg.DoModal();
/* MSG msg;
while (GetMessage(&msg, 0, 0, 0))
DispatchMessage(&msg);*/
_Module.RevokeClassObjects();
Sleep(dwPause); //wait for any threads to finish
}
8. 컴파일 하면 dlg 가 뜨고, 초기 홈페이지를 Load 합니다.
더 자세한 것은 또 문의 하세요... (될수 있으면 E-Mail 은 피해 주세요)
|
http://kr.blog.yahoo.com/jhanglim/trackback/13/89
|
|
|
|
|
|