> For the complete documentation index, see [llms.txt](https://pinvokeisalive.gitbook.io/pinvoke/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pinvokeisalive.gitbook.io/pinvoke/desktopfunctions/credui/credpackauthenticationbuffer.md).

# CredPackAuthenticationBuffer

### C# Signature:

```cs
[DllImport("credui.dll", CharSet = CharSet.Unicode, SetLastError = true)]
    private static extern Boolean CredPackAuthenticationBuffer(
      int dwFlags,
      string pszUserName,
      string pszPassword,
      IntPtr pPackedCredentials,
      ref int pcbPackedCredentials);
```

### VB Signature:

```cs
''' <summary>
    ''' Windows Platform function (called via pInvoke) which populates an authentication buffer with authentication details.
    ''' See http://msdn.microsoft.com/en-us/library/aa374802(v=vs.85).aspx
    ''' </summary>
    ''' <param name="dwFlags">RESERVED - must be zero.</param>
    ''' <param name="pszUserName">User Name.</param>
    ''' <param name="pszPassword">Password.</param>
    ''' <param name="pPackedCredentials">The buffer to be packed with credentials.</param>
    ''' <param name="pcbPackedCredentials">The the size of the buffer.</param>
    ''' <returns><c>True</c> on success; otherwise <c>False</c>. For extended error information, call the GetLastError() function.</returns>
    <DllImport("credui.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> <CLSCompliant(False)> _
    Public Shared Function CredPackAuthenticationBuffer(ByVal dwFlags As UInt32, ByVal pszUserName As String, ByVal pszPassword As String, ByVal pPackedCredentials As IntPtr, ByRef pcbPackedCredentials As UInt32) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function
```

### Sample Code:

```cs
string username = "User";
    string password = "";
    int inCredSize = 1024;
    IntPtr inCredBuffer = Marshal.AllocCoTaskMem(inCredSize);

    CredPackAuthenticationBuffer(0, username, password, inCredBuffer, ref inCredSize);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://pinvokeisalive.gitbook.io/pinvoke/desktopfunctions/credui/credpackauthenticationbuffer.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.
