473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

MapViewOfFile -> 'The specified procedure could not be found.'

I get the error: 'The specified procedure could not be found.' Anyone know why?

I get the error to the call of the function MapViewOfFile():

Private Const FILE_MAP_ALL_ACCESS As Integer = &H1 Or &H2 Or &H4 Or &H8
Or &H10 Or &HF0000

Private Declare Auto Function MapViewOfFile Lib "kernel32" ( _
ByVal hFileMappingObject As IntPtr, _
ByVal dwDesiredAccess As Integer, _
ByVal dwFileOffsetHigh As Integer, _
ByVal dwFileOffsetLow As Integer, _
ByVal dwNumberOfBytesToMap As Integer) As Integer

Function SendCommand(ByVal hwnd As IntPtr, ByVal command As String) As
Boolean
Dim hMapFile As IntPtr
Dim mData As String
Dim result As Boolean = False
Dim errorMessage As String

hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, 0,
PAGE_READWRITE, 0, 4096, "mIRC")

mData = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0).ToString
errorMessage = New Win32Exception(Marshal.GetLastWin32Error()).Messag e

wsprintf(mData, command)

SendMessage(hwnd, WM_MCOMMAND, vbNull, vbNullString)

If mData = "1" Then
result = True
End If

UnmapViewOfFile(mData)
CloseHandle(hMapFile)

Return result
End Function

Nov 21 '05 #1
5 2133
On 2005-02-06, bradtm <br****@discussions.microsoft.com> wrote:
I get the error: 'The specified procedure could not be found.' Anyone know why?

I get the error to the call of the function MapViewOfFile():

Private Const FILE_MAP_ALL_ACCESS As Integer = &H1 Or &H2 Or &H4 Or &H8
Or &H10 Or &HF0000

Private Declare Auto Function MapViewOfFile Lib "kernel32" ( _
ByVal hFileMappingObject As IntPtr, _
ByVal dwDesiredAccess As Integer, _
ByVal dwFileOffsetHigh As Integer, _
ByVal dwFileOffsetLow As Integer, _
ByVal dwNumberOfBytesToMap As Integer) As Integer


Try removing the Auto from the declaration.

--
Tom Shelton [MVP]
Nov 21 '05 #2
Still same error.

"Tom Shelton" wrote:
On 2005-02-06, bradtm <br****@discussions.microsoft.com> wrote:
I get the error: 'The specified procedure could not be found.' Anyone know why?

I get the error to the call of the function MapViewOfFile():

Private Const FILE_MAP_ALL_ACCESS As Integer = &H1 Or &H2 Or &H4 Or &H8
Or &H10 Or &HF0000

Private Declare Auto Function MapViewOfFile Lib "kernel32" ( _
ByVal hFileMappingObject As IntPtr, _
ByVal dwDesiredAccess As Integer, _
ByVal dwFileOffsetHigh As Integer, _
ByVal dwFileOffsetLow As Integer, _
ByVal dwNumberOfBytesToMap As Integer) As Integer


Try removing the Auto from the declaration.

--
Tom Shelton [MVP]

Nov 21 '05 #3
I get the error: 'The specified procedure could not be found.' Anyone know why?


Do you get an exception thrown with that error message, or is it just
the string you get in errorMessage after the call? As long as the
function succeeds (returns non-zero), you shouldn't bother calling
Marshal.GetLastWin32Error.

BTW, why do you check if the return value converted to a string is
"1"? MapViewOfFile returns a nonzero pointer value if it succeeds.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #4
Ok, that makes sense. I don't get thrown an exception, but the program mIRC
doesn't seem to be getting the message as SendMessage is returning 0. I can't
figure out why since all the other functions seem to be returning correct
values.

btw that return value was just code from somewhere else, which I removed.

Private Const WM_MCOMMAND As Integer = &H102 + 200

Declare Auto Function SendMessage Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Integer

Function SendCommand(ByVal hwnd As IntPtr, ByVal command As String) As
Boolean
Dim hMapFile As IntPtr
Dim mData As Long

' hwnd = 459282
' command = "/msg XBN`grind test"

' Returns: 1684 (IntPtr)
hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, 0,
PAGE_READWRITE, 0, 4096, "mIRC")

' Returns: 8975933078252945408 (Long)
mData = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0,
NumberOfBytes)

' Returns: 2 (Integer)
wsprintf(mData, command)

' Returns: 0 (Integer)
SendMessage(hwnd, WM_MCOMMAND, 0, 0)

' Returns: False
UnmapViewOfFile(mData)

' Returns: False
CloseHandle(hMapFile)

Return True
End Function
"Mattias Sjögren" wrote:
I get the error: 'The specified procedure could not be found.' Anyone know why?


Do you get an exception thrown with that error message, or is it just
the string you get in errorMessage after the call? As long as the
function succeeds (returns non-zero), you shouldn't bother calling
Marshal.GetLastWin32Error.

BTW, why do you check if the return value converted to a string is
"1"? MapViewOfFile returns a nonzero pointer value if it succeeds.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 21 '05 #5
> ' Returns: 8975933078252945408 (Long)
mData = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0,
NumberOfBytes)


Did you change the return type of MapViewOfFile to a Long? Integer was
more correct for Win32, but ideally you should use IntPtr to represent
pointers.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alvin777 | last post by:
I'd like to have data file with many strings and load them at once using MapViewOfFile and unload with UnmapViewOfFile. So I wouldn't have to allocate memory for each string on heap. How can I...
2
by: Jon Harrop | last post by:
Does .NET provide an equivalent of memory mapped files from Linux? -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com/products/?u
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.