Using software api documentation without copyright infringement
<p>I've been starting to worry about the details of software copyright. This brought up the question whether using source code from an official documentation, that is copyrighted as usual, is actually legal? If you for example want to work with Graphics APIs like OpenGL or DirectX, you're basically forced to see how you use these APIs and set things up. Yet the publishers of those API documentations do not put the how-to examples in public domain.</p>
<p>Lets for example consider the following snippet from a <a href="https://docs.microsoft.com/en-us/windows/win32/learnwin32/your-first-windows-program" rel="nofollow noreferrer">Win32 tutorial from Microsoft</a> that shows you how to setup a window:</p>
<pre><code>#ifndef UNICODE
#define UNICODE
#endif 

#include &lt;windows.h&gt;

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
    // Register the window class.
    const wchar_t CLASS_NAME[]  = L&quot;Sample Window Class&quot;;
    
    WNDCLASS wc = { };

    wc.lpfnWndProc   = WindowProc;
    wc.hInstance     = hInstance;
    wc.lpszClassName = CLASS_NAME;

    RegisterClass(&amp;wc);

    // Create the window.

    HWND hwnd = CreateWindowEx(
        0,                              // Optional window styles.
        CLASS_NAME,                     // Window class
        L&quot;Learn to Program Windows&quot;,    // Window text
        WS_OVERLAPPEDWINDOW,            // Window style

        // Size and position
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,

        NULL,       // Parent window    
        NULL,       // Menu
        hInstance,  // Instance handle
        NULL        // Additional application data
        );

    if (hwnd == NULL)
    {
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);

    // Run the message loop.

    MSG msg = { };
    while (GetMessage(&amp;msg, NULL, 0, 0))
    {
        TranslateMessage(&amp;msg);
        DispatchMessage(&amp;msg);
    }

    return 0;
}

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;

    case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hwnd, &amp;ps);



            FillRect(hdc, &amp;ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));

            EndPaint(hwnd, &amp;ps);
        }
        return 0;

    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
</code></pre>
<p>Microsoft's <a href="https://docs.microsoft.com/en-us/legal/termsofuse" rel="nofollow noreferrer">Terms of Use</a> at the bottom of the page clearly state, that use is is limited to personal, non-commercial use. What now? Sure, I can change the code. But then its a derivative work. One idea to overcome this issue might be to have someone else read the documentation and write down the necessary API calls and then have someone else given only those notes figure out how to set everything up by just looking up the plain API calls like <a href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexa" rel="nofollow noreferrer">CreateWindowEx</a>.</p>

<p>The example code explains a procedure or method of accomplishing a goal, in the process conveying certain ideas.</p>
<p><a href="https://www.copyright.gov/title17/92chap1.html#102" rel="nofollow noreferrer">17 USC 102 (b)</a> provides:</p>
<blockquote>
<p>(b) In no case does copyright protection for an original work of authorship extend to any idea, procedure, process, system, method of operation, concept, principle, or discovery, regardless of the form in which it is described, explained, illustrated, or embodied in such work.</p>
</blockquote>
<p>The laws of other countries are similar on this point.  Making use of the procedure or method is not copyright infringement. Under US law, making  use of the example code would probably be a fair use, whatever the license may say. But even if it were not held to be a fair use, writing code that is similar to implement the same procedure is not infringement, because there are only a limited number of ways to implement this procedure, and to protect all of them, would be to protect an idea, which copyright never does.</p>
<p>In general when there are only a few ways to express an idea, or implement  a procedure, copyright cannot be used to protect any of them.</p>

copyright software licensing