# InternetOpen

InternetOpen은 프로세스에서 인터넷을 사용할 수 있도록 세션을 초기화하는 함수입니다.

```cpp
HINTERNET InternetOpenA(
  [in] LPCSTR lpszAgent,
  [in] DWORD  dwAccessType,
  [in] LPCSTR lpszProxy,
  [in] LPCSTR lpszProxyBypass,
  [in] DWORD  dwFlags
);
```

| 인자              | 설명              | 보편적인 값                                                                                                          |
| --------------- | --------------- | --------------------------------------------------------------------------------------------------------------- |
| lpszAgent       | User-Agent      | Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 |
| dwAccessType    | 인터넷 연결 방법       | `INTERNET_OPEN_TYPE_DIRECT`                                                                                     |
| lpszProxy       | 프록시 서버 주소       | NULL                                                                                                            |
| lpszProxyBypass | 프록시를 우회할 도메인 목록 | NULL                                                                                                            |
| dwFlags         | 세션 레벨           | 0                                                                                                               |

## Example

```cpp
#include <windows.h>
#include <wininet.h>
#include <iostream>

#pragma comment(lib, "wininet.lib")

int main() {
    // 인터넷 세션 초기화
    HINTERNET hInternet = InternetOpen(
        L"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
        INTERNET_OPEN_TYPE_DIRECT,
        NULL,                     
        NULL,                
        0                    
    );

    // 초기화 실패 예외처리
    if (hInternet == NULL) {
        std::cout << "InternetOpen failed: " << GetLastError() << std::endl;
        return 0;
    }

    std::cout << "Internet session initialized successfully!" << std::endl;
    InternetCloseHandle(hInternet);
    return 0;
}
```

## References

{% embed url="<https://learn.microsoft.com/ko-kr/windows/win32/api/wininet/nf-wininet-internetopena>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pentestwiki.com/defense-evasion/windows-api/internetopen.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
