Jump to content
Sign in to follow this  

Converting from hwnd to string

Recommended Posts


I have this piece of code

$MapView = DllCall($hDll, [b]"str"[/b], "MapViewOfFile", _
                "hwnd", $hFile[0], _
                "dword", $FILE_MAP_WRITE, _
                "dword", 0, _
                "dword", 0, _
                "dword", 0)

Now "str" should be "hwnd" but if I do, I cannot read the returned string.

In Autoit, is there a manual conversion function which can "cast" or convert a variant into a string?

Share this post

Link to post
Share on other sites

Take a look at it's all there...


You also might want to take a look at excellent example :whistle: ...

; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_MapViewOfFile
; Description....: Maps a view of a file mapping into the address space of a calling process.
; Syntax.........: _WinAPI_MapViewOfFile ( $hMapping [, $iOffset [, $iBytes [, $iAccess]]] )
; Parameters.....: $hMapping - Handle to a file mapping object. The _WinAPI_CreateFileMapping() and _WinAPI_OpenFileMapping()
;                            functions return this handle.
;                $iOffset - The file offset where the view is to begin.
;                $iBytes - The number of bytes of a file mapping to map to a view. All bytes must be within the maximum size
;                            specified by _WinAPI_CreateFileMapping(). If $iBytes is 0, the mapping extends from the specified
;                            offset to the end of the file mapping.
;                $iAccess - The access to the file mapping object. This parameter can be one of the following values.
;                            $FILE_MAP_ALL_ACCESS
;                            $FILE_MAP_COPY
;                            $FILE_MAP_READ
;                            $FILE_MAP_WRITE
;                            Each of the preceding values can be combined with the following value.
;                            $FILE_MAP_EXECUTE
; Return values..: Success - The starting address of the mapped view.
;                Failure - 0 and sets the @error flag to non-zero.
; Author.........: Yashied
; Modified.......:
; Remarks........: For files that are larger than the address space, you can only map a small portion of the file data at one time.
;                When the first view is complete, then you unmap it and map a new view.
; Related........:
; Link...........: @@MsdnLink@@ MapViewOfFile
; Example........: Yes
; ===============================================================================================================================

Func _WinAPI_MapViewOfFile($hMapping, $iOffset = 0, $iBytes = 0, $iAccess = 0x0006)

Local $Ret = DllCall('kernel32.dll', 'ptr', 'MapViewOfFile', 'ptr', $hMapping, 'dword', $iAccess, 'dword', _WinAPI_HiDWord($iOffset), 'dword', _WinAPI_LoDWord($iOffset), 'dword', $iBytes)

If (@error) Or (Not $Ret[0]) Then
Return SetError(1, 0, 0)
Return $Ret[0]
EndFunc ;==>_WinAPI_MapViewOfFile
Edited by KaFu

Share this post

Link to post
Share on other sites


Funny thing is I looked for ages for such UDFs...beautiful finished my app in minutes

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this