# InternetOpenUrl

InternetOpenUrl 함수는 FTP 혹은 HTTP URL로 지정된 리소스를 여는 함수입니다.

```cpp
HINTERNET InternetOpenUrlA(
  [in] HINTERNET hInternet,
  [in] LPCSTR    lpszUrl,
  [in] LPCSTR    lpszHeaders,
  [in] DWORD     dwHeadersLength,
  [in] DWORD     dwFlags,
  [in] DWORD_PTR dwContext
);
```

| 인자              | 설명                      | 보편적인 값                                                 |
| --------------- | ----------------------- | ------------------------------------------------------ |
| hInternet       | InternetOpen 함수가 반환한 핸들 |                                                        |
| lpszUrl         | 접근할 URL                 |                                                        |
| lpszHeaders     | HTTP 추가 헤더              | NULL                                                   |
| dwHeadersLength | 헤더 길이                   | 0                                                      |
| dwFlags         | URL 요청 옵션               | `INTERNET_FLAG_RELOAD \| INTERNET_FLAG_NO_CACHE_WRITE` |
| dwContext       | 비동기 호출 시 식별자            | 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;

    HINTERNET hInternetOpenUrl = InternetOpenUrl(hInternet, L"https://www.pentestwiki.com", NULL, 0, INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE, 0);
    if (!hInternetOpenUrl) {
        std::cout << "InternetOpenUrl failed: " << GetLastError() << std::endl;
        return 0;
    }
    std::cout << "Opening the URL was successfully!" << std::endl;
    InternetCloseHandle(hInternet);
    return 0;
}
```

## References

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


---

# 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/internetopenurl.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.
