Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy

Search Results for "GetLastError" in [All]

kernel32

.
.
3: Beep
.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

.

If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.

.

                    // check GetLastError value (MUST use this call. See MSDN)

.

    private static extern uint GetLastError();*/

.

   Private Declare Function GetLastError Lib "kernel32" Alias "GetLastError" () As Integer

.

       MsgBox(GetLastError())

.

       MsgBox(GetLastError())

.

       MsgBox(GetLastError())

.

       MsgBox(GetLastError())

.

public static int GetLastError()

.

public static string GetLastErrorString()

.

    int lastError = GetLastError();

.

static extern uint GetLastError();

.

// GetLastError is save!

.

Tested extensively here http://stackoverflow.com/questions/17918266/winapi-getlasterror-vs-marshal-getlastwin32error

.

// You should never PInvoke to GetLastError.  Call Marshal.GetLastWin32Error instead!

.

' You should never PInvoke to GetLastError.  Call Marshal.GetLastWin32Error instead!

.

def GetLastError() as int:

.

Calling GetLastError directly via PInvoke is not guaranteed to work due to the CLR's internal interaction with the operating system. Instead, call Marshal.GetLastWin32Error.

.
Documentation
[GetLastError] on MSDN
.

/// If the function fails, the return value is TIME_ZONE_ID_INVALID. To get extended error information, call GetLastError.

.

/// If the function fails, the return value is zero. To get extended error information, call GetLastError.

.

If you forget to set the OSVersionInfoSize field of the OSVERSIONINFO struct, the function will return false. GetLastError() will return:

.

If you forget to set the OSVersionInfoSize field of the OSVERSIONINFO struct, the function will return false. GetLastError() will return:

.

Return Value - If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.

.

The SetLastError flag needs to be set to true in order to retain information that would be obtained from GetLastError in the event of an error being returned.

.

                else if(GetLastError() == ERROR_INSUFFICIENT_BUFFER)

.

                    Marshal.ThrowExceptionForHR(GetLastError());

.

        if (GetLastError() != 0)

.

Call SetLastError(0) at the beginning of your function if you'll use GetLastError.

.

        /// If the function fails, the return value is TIME_ZONE_ID_INVALID. To get extended error information, call GetLastError.

.

        /// If the function fails, the return value is zero. To get extended error information, call GetLastError.

.

static extern uint GetLastError();

.

           throw new Win32Exception((int)GetLastError());

.

           throw new Win32Exception((int)GetLastError());

Enums

.

    // will fail and GetLastError() will indicate ERROR_PASSWORD_RESTRICTION

.

    ' will fail and GetLastError() will indicate ERROR_PASSWORD_RESTRICTION

.

     /// This value returns <B>FALSE</B>. If you call <see cref="GetLastError"/> to get extended error information, <B>GetLastError</B> returns <B>ERROR_NOT_SUPPORTED</B>.

.

     /// This value returns <B>FALSE</B>. If you call <see cref="GetLastError"/> to get extended error information, <B>GetLastError</B> returns <B>ERROR_NOT_SUPPORTED</B>.

.

     /// This value returns <B>FALSE</B>. If you call <see cref="GetLastError"/> to get extended error information, <B>GetLastError</B> returns <B>ERROR_NOT_SUPPORTED</B>.

.

     /// This value returns <B>FALSE</B>. If you call <see cref="GetLastError"/> to get extended error information, <B>GetLastError</B> returns <B>ERROR_NOT_SUPPORTED</B>.

.

     /// This value returns <B>FALSE</B>. If you call <see cref="GetLastError"/> to get extended error information, <B>GetLastError</B> returns <B>ERROR_NOT_SUPPORTED</B>.

.

     /// This value returns <B>FALSE</B>. If you call <see cref="GetLastError"/> to get extended error information, <B>GetLastError</B> returns <B>ERROR_NOT_SUPPORTED</B>.

misc

.

I'd go so far as to recommend always mandating SetLastError -- explicitly setting SetLastError=false, to call out the (comparatively rare) Win32 functions that don't expose a failure path through GetLastError.

psapi

.

                Console.WriteLine("Call to EnumDeviceDrivers failed!  To get extended error information, call GetLastError.");

.

                Console.WriteLine("Call to EnumDeviceDrivers failed!  To get extended error information, call GetLastError.");

.

                Console.WriteLine("Call to EnumDeviceDrivers failed!  To get extended error information, call GetLastError.");

.

                Console.WriteLine("Call to EnumDeviceDrivers failed!  To get extended error information, call GetLastError.");

user32

.

If the clipboard is not owned, the return value is NULL. To get extended error information, call GetLastError.

27: GetDC
.

Windows NT/2000/XP: To get extended error information, call GetLastError.

.

Windows NT/2000/XP: To get extended error information, call GetLastError.

.

static extern uint GetLastError(TODO);

.

Declare Function GetLastError Lib "kernel32.dll" (TODO) As TODO

.
Documentation
[GetLastError] on MSDN
.

    int nLatError = GetLastError(); // in kernel32.dll

.

/// to the specified window, the return value is NULL. To get extended error information, call GetLastError.

.

///     call GetLastError.

.

///     or control handle is invalid, the return value is zero. To get extended error information, call GetLastError.<br />

.

///     <br />To get extended error information, call GetLastError.

.

    ''' <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para></returns>

.

MSDN says: If the function fails, the return value is zero. To get extended error information, call GetLastError.

.

///     information, call GetLastError.

.

/// <para>Windows Vista: RemoveProp is subject to the restrictions of User Interface Privilege Isolation (UIPI). A process can only call this function on a window belonging to a process of lesser or equal integrity level. When UIPI blocks property changes, GetLastError will return 5.</para>

.

/// <para>Windows Vista: SetProp is subject to the restrictions of User Interface Privilege Isolation (UIPI). A process can only call this function on a window belonging to a process of lesser or equal integrity level. When UIPI blocks property changes, GetLastError will return 5.</para>

.

/// <returns>If the data handle and string are added to the property list, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.</returns>

.

/// If the function fails, the return value is zero. To get extended error information, call GetLastError.

.

///     To get extended error information, call GetLastError.

icmp

.

        printf("IcmpCreatefile returned error: %ld\n", GetLastError());

msi

.

static extern IntPtr MsiGetLastErrorRecord();

.
Documentation
[MsiGetLastErrorRecord] on MSDN

gdi32

.

If the function succeeds, the return value is a handle to the newly created device-independent bitmap (and ppvBits will point to the bitmap’s bit values). If the function fails, the return value is NULL (and ptr ppvBits will be NULL). To get extended error information, call GetLastError.

mpr

.

static extern TODO WNetGetLastErrorA(ref int lpError,ref string lpErrorBuf,int nErrorBufSize,string lpNameBuf,int nNameBufSize);

.

public static extern uint WNetGetLastError(ref int lpError,StringBuilder lpErrorBuf,int nErrorBufSize,StringBuilder lpNameBuf,int nNameBufSize);

.

Declare Function WNetGetLastError Lib "mpr.dll" Alias "WNetGetLastErrorA" (ByRef lpError As Integer, ByVal lpErrorBuf As String, ByVal nErrorBufSize As Integer, ByVal lpNameBuf As String, ByVal nNameBufSize As Integer) As Integer

.
Documentation
[WNetGetLastError] on MSDN

userenv

.

Otherwise, if the function fails, the return value is zero. To get extended error information, call GetLastError.

setupapi

.

SP_COPY_NOOVERWRITE Copy only if the specified files don't currently exist in the INF directory. If the INF does currently exist, this API will fail and GetLastError returns ERROR_FILE_EXISTS. In this case, the existing INF file's filename will be placed into the appropriate field in the destination INF file's information output buffers.

.

in Size of the DestinationInfFileName buffer, in characters, or zero if the buffer is not specified. If DestinationInfFileName is specified and this buffer size is less than the size required to return the destination INF filename (including full path), this function will fail. In this case GetLastError will return ERROR_INSUFFICIENT_BUFFER.

.

The SetupCopyOEMInf function failed. For extended error information, call GetLastError.

.

        ErrorCode = GetLastError();

.

A call to SetupDiEnumDeviceInterfaces retrieves a pointer to a structure that identifies a specific device interface in the previously retrieved DeviceInfoSet array. The call specifies a device interface by passing an array index. To retrieve information about all of the device interfaces, an application can loop through the array, incrementing the array index until the function returns zero, indicating that there are no more interfaces. The GetLastError API function then returns No more data is available.

.

If the function could not find a line, the return value is zero. To get extended error information, call GetLastError.

.

If this function finds the next line, the return value is a nonzero value. Otherwise, the return value is zero. To get extended error information, call GetLastError.

.

The function returns a nonzero value if it finds a matching line. Otherwise, the return value is zero. To get extended error information, call GetLastError.

.
RequiredSize Optional pointer to a variable that receives the required size for the buffer pointed to by the ReturnBuffer parameter, in characters. If ReturnBuffer is specified and the actual size needed is larger than the value specified by ReturnBufferSize, the function fails and does not store the string in the buffer. In this case, a call to GetLastError returns ERROR_INSUFFICIENT_BUFFER. For the Unicode version of this function, the required size is in characters. This includes the null terminator.
.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

.

If this function is called with a ReturnBuffer of NULL and a ReturnBufferSize of zero, the function puts the buffer size needed to hold the specified data into the variable pointed to by RequiredSize. If the function succeeds in this, the return value is a nonzero value. Otherwise, the return value is zero and extended error information can be obtained by calling GetLastError. You can call the function once to get the required buffer size, allocate the necessary memory, and then call the function a second time to retrieve the data. Using this technique, you can avoid errors due to an insufficient buffer size.

.
ErrorLine Optional pointer to a variable to which this function returns the (1-based) line number where an error occurred during loading of the INF file. This value is generally reliable only if GetLastError does not return ERROR_NOT_ENOUGH_MEMORY. If an out-of-memory condition does occur, ErrorLine may be 0.
.

The function returns a handle to the opened INF file if it is successful. Otherwise, the return value is INVALID_HANDLE_VALUE. Extended error information can be retrieved by a call to GetLastError.

.

If the load fails because the INF file type does not match InfClass, the function returns INVALID_HANDLE_VALUE and a call to GetLastError returns ERROR_CLASS_MISMATCH.

wtsapi32

.

As always, only do SetLastError=true if you actually intend to call GetLastError.

.

/// If the function fails, the return value is zero. To get extended error information, call GetLastError.

.

    /// If the function fails, the return value is zero. To get extended error information, call GetLastError.

shlwapi

.

/// <returns>Returns TRUE if the file exists, or FALSE otherwise. Call GetLastError for extended error information.</returns>

.

''' <returns>Returns TRUE if the file exists, or FALSE otherwise. Call GetLastError for extended error information.</returns>

advapi32

.

If the function cannot find an account name for the SID, the LookupAccountSid function fails and GetLastError returns ERROR_NONE_MAPPED. This can occur if a network time-out prevents the function from finding the name. It also occurs for SIDs that have no corresponding account name, such as a logon SID that identifies a logon session.

.

        aWinErrorCode = (uint)GetLastError();

.

public static void SetFileOrFolderOwner(String objectName) //Note this is very basic and is silent on fail as I havent checked GetlastError and thrown an exception etc

rapi

. .

public static extern int CeGetLastError();

.

function info on msdn at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceactsy/html/cerefCeGetLastErrorRAPI.asp

.
Documentation
[CeGetLastError] on MSDN

Cut off search results after 60. Please refine your search.


 
Access PInvoke.net directly from VS: