Declare and use this API function makeintresource in VB

Source: Internet
Author: User
Loadmenu:
Hmenu loadmenu (hinstance, // handle to module lpctstr lpmenuname // menu name or resource identifier );
The parameter lpmenuname is generated using makeintresource, while
# Define makeintresourcea (I) (lpstr) (DWORD) (Word) (I) # define makeintresourcew (I) (lpwstr) (DWORD) (word) (I) # ifdef Unicode # define makeintresource makeintresourcew # else # define makeintresource makeintresourcea # endif //! Unicode
In VC, the key in VB is to translate macro makeintresource, some API declaration tools declare loadmenuprivate declare function loadmenu lib "user32.dll" alias "loadmenua" (byval hinstance as long, byval lpstring as string) as long. The last parameter is string, then, according to the macro makeintresource statement, although this macro converts word to lpstr (lpwstr), the actual data has not changed. Therefore, in VB, the second parameter is actually the same with long, so we should change it like this,
Private declare function loadmenu lib "user32.dll" alias "loadmenua" (byval hinstance as long, byval lpstring as long) as long
Solve all the problems (there may be still some problems, otherwise there will be no macro makeintresource)
VB example:
Option explicit
Private declare function loadlibrary lib "kernel32.dll" alias "loadlibrarya" (byval lplibfilename as string) as longprivate declare function loadmenu lib "user32.dll" alias "loadmenua" (byval hinstance as long, byval lpstring as long) as longprivate declare function setmenu lib "user32.dll" (byval hwnd as long, byval hmenu as long) as long
Private sub commandrentclick () dim tmenu & tmenu = loadmenuvb2 (24641, "shdoclc. dll") setmenu me. hwnd, tmenuend sub
Public Function loadmenuvb2 (ID &, slib $) as longdim hinstshdoclc & dim hmenu & hinstshdoclc = loadlibrary (slib)
Loadmenuvb2 = loadmenu (hinstshdoclc, byval ID)
End Function
(Freelibrary, huh, huh)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.