Microsoft Visual Basic: Why does LoadLibrary fail?

  • andrew / 112 / Tues, 09 Mar 2010 15:20:00 GMT / Comments (14)
  • I recently downloaded a sample app that resizes a background image on a MDI
    form. The app works fine but if I modify it I cant get it to work in the
    IDE, however the .exe works fine.

    The sample uses the following code to get resources from the compiled app
    while running in the IDE.

    If RunningInIde() Then
    hModule = LoadLibrary("PMDIBackground.exe")
    Else
    hModule = App.hInstance
    End If

    I think the problem is something to do with compiling the .exe as LoadLibrary
    only works when pointed at the original .exe. and even if I create a new
    .exe from the original unmodified code it fails.

    I have tried all the different options on the compile tab except advanced
    options to no avail.

    I have never compile anything with a resource file before, could I be missing
    something there?

    Thanks in advance.
  • Keywords:

    loadlibrary, fail, microsoft, visual basic, vb

  • http://www.edevs.com/visual-basic/71737/«« Last Thread - Next Thread »»
    1. Andrew, I would suggest first that you use the LoadLibraryEx function with
      the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.

      Next I would question if the function can even find the file; perhaps try an
      absolute path first, then worry about the relative path spec once you get it
      working.

      Hope this helps.

      ++++++++++++++++++++
      Monte Hansen
      http://KillerVB.com
      ++++++++++++++++++++

      "Andrew" <jordan...sol-3.co.uk> wrote in message
      news:3b8cd18a$1...news.dev-archive.com...
      >
      > I recently downloaded a sample app that resizes a background image on a
      MDI
      > form. The app works fine but if I modify it I cant get it to work in the
      > IDE, however the .exe works fine.
      >
      > The sample uses the following code to get resources from the compiled app
      > while running in the IDE.
      >
      > If RunningInIde() Then
      > hModule = LoadLibrary("PMDIBackground.exe")
      > Else
      > hModule = App.hInstance
      > End If
      >
      > I think the problem is something to do with compiling the .exe as
      LoadLibrary
      > only works when pointed at the original .exe. and even if I create a new
      > exe from the original unmodified code it fails.
      >
      > I have tried all the different options on the compile tab except advanced
      > options to no avail.
      >
      > I have never compile anything with a resource file before, could I be
      missing
      > something there?
      >
      > Thanks in advance.

      montehansen | Sun, 11 Nov 2007 18:47:54 GMT |

    2. Andrew, I would suggest first that you use the LoadLibraryEx function with
      the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.

      Next I would question if the function can even find the file; perhaps try an
      absolute path first, then worry about the relative path spec once you get it
      working.

      Hope this helps.

      ++++++++++++++++++++
      Monte Hansen
      http://KillerVB.com
      ++++++++++++++++++++

      "Andrew" <jordan...sol-3.co.uk> wrote in message
      news:3b8cd18a$1...news.dev-archive.com...
      >
      > I recently downloaded a sample app that resizes a background image on a
      MDI
      > form. The app works fine but if I modify it I cant get it to work in the
      > IDE, however the .exe works fine.
      >
      > The sample uses the following code to get resources from the compiled app
      > while running in the IDE.
      >
      > If RunningInIde() Then
      > hModule = LoadLibrary("PMDIBackground.exe")
      > Else
      > hModule = App.hInstance
      > End If
      >
      > I think the problem is something to do with compiling the .exe as
      LoadLibrary
      > only works when pointed at the original .exe. and even if I create a new
      > exe from the original unmodified code it fails.
      >
      > I have tried all the different options on the compile tab except advanced
      > options to no avail.
      >
      > I have never compile anything with a resource file before, could I be
      missing
      > something there?
      >
      > Thanks in advance.

      montehansen | Sun, 11 Nov 2007 18:49:00 GMT |

    3. Thanks Monte, but I am getting the same results with LoadLibraryEx and the
      absolute path.

      "Monte Hansen" <monte...nospam.com> wrote:
      >Andrew, I would suggest first that you use the LoadLibraryEx function with
      >the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >
      >Next I would question if the function can even find the file; perhaps try
      an
      >absolute path first, then worry about the relative path spec once you get
      it
      >working.
      >
      >Hope this helps.
      >
      >++++++++++++++++++++
      >Monte Hansen
      >http://KillerVB.com
      >++++++++++++++++++++
      >
      >"Andrew" <jordan...sol-3.co.uk> wrote in message
      >news:3b8cd18a$1...news.dev-archive.com...
      >>
      >> I recently downloaded a sample app that resizes a background image on
      a
      >MDI
      >> form. The app works fine but if I modify it I cant get it to work in the
      >> IDE, however the .exe works fine.
      >>
      >> The sample uses the following code to get resources from the compiled
      app
      >> while running in the IDE.
      >>
      >> If RunningInIde() Then
      >> hModule = LoadLibrary("PMDIBackground.exe")
      >> Else
      >> hModule = App.hInstance
      >> End If
      >>
      >> I think the problem is something to do with compiling the .exe as
      >LoadLibrary
      >> only works when pointed at the original .exe. and even if I create a new
      >> exe from the original unmodified code it fails.
      >>
      >> I have tried all the different options on the compile tab except advanced
      >> options to no avail.
      >>
      >> I have never compile anything with a resource file before, could I be
      >missing
      >> something there?
      >>
      >> Thanks in advance.
      >
      >

      andrew | Sun, 11 Nov 2007 18:50:03 GMT |

    4. Thanks Monte, but I am getting the same results with LoadLibraryEx and the
      absolute path.

      "Monte Hansen" <monte...nospam.com> wrote:
      >Andrew, I would suggest first that you use the LoadLibraryEx function with
      >the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >
      >Next I would question if the function can even find the file; perhaps try
      an
      >absolute path first, then worry about the relative path spec once you get
      it
      >working.
      >
      >Hope this helps.
      >
      >++++++++++++++++++++
      >Monte Hansen
      >http://KillerVB.com
      >++++++++++++++++++++
      >
      >"Andrew" <jordan...sol-3.co.uk> wrote in message
      >news:3b8cd18a$1...news.dev-archive.com...
      >>
      >> I recently downloaded a sample app that resizes a background image on
      a
      >MDI
      >> form. The app works fine but if I modify it I cant get it to work in the
      >> IDE, however the .exe works fine.
      >>
      >> The sample uses the following code to get resources from the compiled
      app
      >> while running in the IDE.
      >>
      >> If RunningInIde() Then
      >> hModule = LoadLibrary("PMDIBackground.exe")
      >> Else
      >> hModule = App.hInstance
      >> End If
      >>
      >> I think the problem is something to do with compiling the .exe as
      >LoadLibrary
      >> only works when pointed at the original .exe. and even if I create a new
      >> exe from the original unmodified code it fails.
      >>
      >> I have tried all the different options on the compile tab except advanced
      >> options to no avail.
      >>
      >> I have never compile anything with a resource file before, could I be
      >missing
      >> something there?
      >>
      >> Thanks in advance.
      >
      >

      andrew | Sun, 11 Nov 2007 18:51:03 GMT |

    5. What's Err.LastDllError? What's the O/S?

      Do these exceptions apply?:
      --------
      Windows 95/98/Me: If you are using LoadLibraryEx to load a module that contains
      a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      fails. If you are attempting to load a 16-bit DLL directly from 32-bit code,
      LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      version is greater than 4.0, LoadLibraryEx fails. If your DllMain function
      tries to call the Unicode version of a Win32 function, LoadLibraryEx fails.

      Also, FYI, I would still use the Ex version as a matter of practice :)

      ++++++++++++++++++++
      Monte Hansen
      http://KillerVB.com
      ++++++++++++++++++++

      "Andrew" <jordan...sol-3.co.uk> wrote:
      >
      >Thanks Monte, but I am getting the same results with LoadLibraryEx and the
      >absolute path.
      >
      >"Monte Hansen" <monte...nospam.com> wrote:
      >>Andrew, I would suggest first that you use the LoadLibraryEx function with
      >>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >>
      >>Next I would question if the function can even find the file; perhaps try
      >an
      >>absolute path first, then worry about the relative path spec once you get
      >it
      >>working.
      >>
      >>Hope this helps.
      >>
      >>++++++++++++++++++++
      >>Monte Hansen
      >>http://KillerVB.com
      >>++++++++++++++++++++
      >>
      >>"Andrew" <jordan...sol-3.co.uk> wrote in message
      >>news:3b8cd18a$1...news.dev-archive.com...
      >>>
      >>> I recently downloaded a sample app that resizes a background image on
      >a
      >>MDI
      >>> form. The app works fine but if I modify it I cant get it to work in
      the
      >>> IDE, however the .exe works fine.
      >>>
      >>> The sample uses the following code to get resources from the compiled
      >app
      >>> while running in the IDE.
      >>>
      >>> If RunningInIde() Then
      >>> hModule = LoadLibrary("PMDIBackground.exe")
      >>> Else
      >>> hModule = App.hInstance
      >>> End If
      >>>
      >>> I think the problem is something to do with compiling the .exe as
      >>LoadLibrary
      >>> only works when pointed at the original .exe. and even if I create a
      new
      >>> exe from the original unmodified code it fails.
      >>>
      >>> I have tried all the different options on the compile tab except advanced
      >>> options to no avail.
      >>>
      >>> I have never compile anything with a resource file before, could I be
      >>missing
      >>> something there?
      >>>
      >>> Thanks in advance.
      >>
      >>
      >

      montehansen | Sun, 11 Nov 2007 18:52:02 GMT |

    6. What's Err.LastDllError? What's the O/S?

      Do these exceptions apply?:
      --------
      Windows 95/98/Me: If you are using LoadLibraryEx to load a module that contains
      a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      fails. If you are attempting to load a 16-bit DLL directly from 32-bit code,
      LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      version is greater than 4.0, LoadLibraryEx fails. If your DllMain function
      tries to call the Unicode version of a Win32 function, LoadLibraryEx fails.

      Also, FYI, I would still use the Ex version as a matter of practice :)

      ++++++++++++++++++++
      Monte Hansen
      http://KillerVB.com
      ++++++++++++++++++++

      "Andrew" <jordan...sol-3.co.uk> wrote:
      >
      >Thanks Monte, but I am getting the same results with LoadLibraryEx and the
      >absolute path.
      >
      >"Monte Hansen" <monte...nospam.com> wrote:
      >>Andrew, I would suggest first that you use the LoadLibraryEx function with
      >>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >>
      >>Next I would question if the function can even find the file; perhaps try
      >an
      >>absolute path first, then worry about the relative path spec once you get
      >it
      >>working.
      >>
      >>Hope this helps.
      >>
      >>++++++++++++++++++++
      >>Monte Hansen
      >>http://KillerVB.com
      >>++++++++++++++++++++
      >>
      >>"Andrew" <jordan...sol-3.co.uk> wrote in message
      >>news:3b8cd18a$1...news.dev-archive.com...
      >>>
      >>> I recently downloaded a sample app that resizes a background image on
      >a
      >>MDI
      >>> form. The app works fine but if I modify it I cant get it to work in
      the
      >>> IDE, however the .exe works fine.
      >>>
      >>> The sample uses the following code to get resources from the compiled
      >app
      >>> while running in the IDE.
      >>>
      >>> If RunningInIde() Then
      >>> hModule = LoadLibrary("PMDIBackground.exe")
      >>> Else
      >>> hModule = App.hInstance
      >>> End If
      >>>
      >>> I think the problem is something to do with compiling the .exe as
      >>LoadLibrary
      >>> only works when pointed at the original .exe. and even if I create a
      new
      >>> exe from the original unmodified code it fails.
      >>>
      >>> I have tried all the different options on the compile tab except advanced
      >>> options to no avail.
      >>>
      >>> I have never compile anything with a resource file before, could I be
      >>missing
      >>> something there?
      >>>
      >>> Thanks in advance.
      >>
      >>
      >

      montehansen | Sun, 11 Nov 2007 18:53:02 GMT |

    7. Thanks again Monte, the o/s is Windows 98, Err.LastDllError returns 0 with
      the original .exe, but returns 11 with the newly compiled but unaltered source
      code.exe.

      I cant find any documentation to explain the error code.

      Any explanation would be gratefully recieved.

      "Monte Hansen" <monte...nospam.com> wrote:
      >
      >What's Err.LastDllError? What's the O/S?
      >
      >Do these exceptions apply?:
      >--------
      >Windows 95/98/Me: If you are using LoadLibraryEx to load a module that contains
      >a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      >fails. If you are attempting to load a 16-bit DLL directly from 32-bit code,
      >LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      >version is greater than 4.0, LoadLibraryEx fails. If your DllMain function
      >tries to call the Unicode version of a Win32 function, LoadLibraryEx fails.
      >
      >
      >Also, FYI, I would still use the Ex version as a matter of practice :)
      >
      >++++++++++++++++++++
      >Monte Hansen
      >http://KillerVB.com
      >++++++++++++++++++++
      >
      >
      >"Andrew" <jordan...sol-3.co.uk> wrote:
      >>
      >>Thanks Monte, but I am getting the same results with LoadLibraryEx and
      the
      >>absolute path.
      >>
      >>"Monte Hansen" <monte...nospam.com> wrote:
      >>>Andrew, I would suggest first that you use the LoadLibraryEx function
      with
      >>>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >>>
      >>>Next I would question if the function can even find the file; perhaps
      try
      >>an
      >>>absolute path first, then worry about the relative path spec once you
      get
      >>it
      >>>working.
      >>>
      >>>Hope this helps.
      >>>
      >>>++++++++++++++++++++
      >>>Monte Hansen
      >>>http://KillerVB.com
      >>>++++++++++++++++++++
      >>>
      >>>"Andrew" <jordan...sol-3.co.uk> wrote in message
      >>>news:3b8cd18a$1...news.dev-archive.com...
      >>>>
      >>>> I recently downloaded a sample app that resizes a background image on
      >>a
      >>>MDI
      >>>> form. The app works fine but if I modify it I cant get it to work in
      >the
      >>>> IDE, however the .exe works fine.
      >>>>
      >>>> The sample uses the following code to get resources from the compiled
      >>app
      >>>> while running in the IDE.
      >>>>
      >>>> If RunningInIde() Then
      >>>> hModule = LoadLibrary("PMDIBackground.exe")
      >>>> Else
      >>>> hModule = App.hInstance
      >>>> End If
      >>>>
      >>>> I think the problem is something to do with compiling the .exe as
      >>>LoadLibrary
      >>>> only works when pointed at the original .exe. and even if I create a
      >new
      >>>> exe from the original unmodified code it fails.
      >>>>
      >>>> I have tried all the different options on the compile tab except advanced
      >>>> options to no avail.
      >>>>
      >>>> I have never compile anything with a resource file before, could I be
      >>>missing
      >>>> something there?
      >>>>
      >>>> Thanks in advance.
      >>>
      >>>
      >>
      >

      andrew | Sun, 11 Nov 2007 18:54:06 GMT |

    8. Thanks again Monte, the o/s is Windows 98, Err.LastDllError returns 0 with
      the original .exe, but returns 11 with the newly compiled but unaltered source
      code.exe.

      I cant find any documentation to explain the error code.

      Any explanation would be gratefully recieved.

      "Monte Hansen" <monte...nospam.com> wrote:
      >
      >What's Err.LastDllError? What's the O/S?
      >
      >Do these exceptions apply?:
      >--------
      >Windows 95/98/Me: If you are using LoadLibraryEx to load a module that contains
      >a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      >fails. If you are attempting to load a 16-bit DLL directly from 32-bit code,
      >LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      >version is greater than 4.0, LoadLibraryEx fails. If your DllMain function
      >tries to call the Unicode version of a Win32 function, LoadLibraryEx fails.
      >
      >
      >Also, FYI, I would still use the Ex version as a matter of practice :)
      >
      >++++++++++++++++++++
      >Monte Hansen
      >http://KillerVB.com
      >++++++++++++++++++++
      >
      >
      >"Andrew" <jordan...sol-3.co.uk> wrote:
      >>
      >>Thanks Monte, but I am getting the same results with LoadLibraryEx and
      the
      >>absolute path.
      >>
      >>"Monte Hansen" <monte...nospam.com> wrote:
      >>>Andrew, I would suggest first that you use the LoadLibraryEx function
      with
      >>>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >>>
      >>>Next I would question if the function can even find the file; perhaps
      try
      >>an
      >>>absolute path first, then worry about the relative path spec once you
      get
      >>it
      >>>working.
      >>>
      >>>Hope this helps.
      >>>
      >>>++++++++++++++++++++
      >>>Monte Hansen
      >>>http://KillerVB.com
      >>>++++++++++++++++++++
      >>>
      >>>"Andrew" <jordan...sol-3.co.uk> wrote in message
      >>>news:3b8cd18a$1...news.dev-archive.com...
      >>>>
      >>>> I recently downloaded a sample app that resizes a background image on
      >>a
      >>>MDI
      >>>> form. The app works fine but if I modify it I cant get it to work in
      >the
      >>>> IDE, however the .exe works fine.
      >>>>
      >>>> The sample uses the following code to get resources from the compiled
      >>app
      >>>> while running in the IDE.
      >>>>
      >>>> If RunningInIde() Then
      >>>> hModule = LoadLibrary("PMDIBackground.exe")
      >>>> Else
      >>>> hModule = App.hInstance
      >>>> End If
      >>>>
      >>>> I think the problem is something to do with compiling the .exe as
      >>>LoadLibrary
      >>>> only works when pointed at the original .exe. and even if I create a
      >new
      >>>> exe from the original unmodified code it fails.
      >>>>
      >>>> I have tried all the different options on the compile tab except advanced
      >>>> options to no avail.
      >>>>
      >>>> I have never compile anything with a resource file before, could I be
      >>>missing
      >>>> something there?
      >>>>
      >>>> Thanks in advance.
      >>>
      >>>
      >>
      >

      andrew | Sun, 11 Nov 2007 18:55:01 GMT |

    9. In your "Microsoft Visual Studio 6.0\Microsoft Visual Studio 6.0 Tools" menu,
      you will find a tool called "Error Lookup". Punch in "11" and you get the
      error description of:

      >An attempt was made to load a program with an incorrect format.

      Your problem is documented in the SDK, and in this article:
      PRB: Cannot Load Module with Resource ID Greater Than 32767 (0x7FFF)
      Q137248

      ++++++++++++++++++++
      Monte Hansen
      http://KillerVB.com
      ++++++++++++++++++++

      "Andrew" <jordan...sol-3.co.uk> wrote:
      >
      >Thanks again Monte, the o/s is Windows 98, Err.LastDllError returns 0 with
      >the original .exe, but returns 11 with the newly compiled but unaltered
      source
      >code.exe.
      >
      >I cant find any documentation to explain the error code.
      >
      >Any explanation would be gratefully recieved.
      >
      >"Monte Hansen" <monte...nospam.com> wrote:
      >>
      >>What's Err.LastDllError? What's the O/S?
      >>
      >>Do these exceptions apply?:
      >>--------
      >>Windows 95/98/Me: If you are using LoadLibraryEx to load a module that
      contains
      >>a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      >>fails. If you are attempting to load a 16-bit DLL directly from 32-bit
      code,
      >>LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      >>version is greater than 4.0, LoadLibraryEx fails. If your DllMain function
      >>tries to call the Unicode version of a Win32 function, LoadLibraryEx fails.
      >>
      >>
      >>Also, FYI, I would still use the Ex version as a matter of practice :)
      >>
      >>++++++++++++++++++++
      >>Monte Hansen
      >>http://KillerVB.com
      >>++++++++++++++++++++
      >>
      >>
      >>"Andrew" <jordan...sol-3.co.uk> wrote:
      >>>
      >>>Thanks Monte, but I am getting the same results with LoadLibraryEx and
      >the
      >>>absolute path.
      >>>
      >>>"Monte Hansen" <monte...nospam.com> wrote:
      >>>>Andrew, I would suggest first that you use the LoadLibraryEx function
      >with
      >>>>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >>>>
      >>>>Next I would question if the function can even find the file; perhaps
      >try
      >>>an
      >>>>absolute path first, then worry about the relative path spec once you
      >get
      >>>it
      >>>>working.
      >>>>
      >>>>Hope this helps.
      >>>>
      >>>>++++++++++++++++++++
      >>>>Monte Hansen
      >>>>http://KillerVB.com
      >>>>++++++++++++++++++++
      >>>>
      >>>>"Andrew" <jordan...sol-3.co.uk> wrote in message
      >>>>news:3b8cd18a$1...news.dev-archive.com...
      >>>>>
      >>>>> I recently downloaded a sample app that resizes a background image
      on
      >>>a
      >>>>MDI
      >>>>> form. The app works fine but if I modify it I cant get it to work in
      >>the
      >>>>> IDE, however the .exe works fine.
      >>>>>
      >>>>> The sample uses the following code to get resources from the compiled
      >>>app
      >>>>> while running in the IDE.
      >>>>>
      >>>>> If RunningInIde() Then
      >>>>> hModule = LoadLibrary("PMDIBackground.exe")
      >>>>> Else
      >>>>> hModule = App.hInstance
      >>>>> End If
      >>>>>
      >>>>> I think the problem is something to do with compiling the .exe as
      >>>>LoadLibrary
      >>>>> only works when pointed at the original .exe. and even if I create
      a
      >>new
      >>>>> exe from the original unmodified code it fails.
      >>>>>
      >>>>> I have tried all the different options on the compile tab except advanced
      >>>>> options to no avail.
      >>>>>
      >>>>> I have never compile anything with a resource file before, could I
      be
      >>>>missing
      >>>>> something there?
      >>>>>
      >>>>> Thanks in advance.
      >>>>
      >>>>
      >>>
      >>
      >

      montehansen | Sun, 11 Nov 2007 18:56:02 GMT |

    10. In your "Microsoft Visual Studio 6.0\Microsoft Visual Studio 6.0 Tools" menu,
      you will find a tool called "Error Lookup". Punch in "11" and you get the
      error description of:

      >An attempt was made to load a program with an incorrect format.

      Your problem is documented in the SDK, and in this article:
      PRB: Cannot Load Module with Resource ID Greater Than 32767 (0x7FFF)
      Q137248

      ++++++++++++++++++++
      Monte Hansen
      http://KillerVB.com
      ++++++++++++++++++++

      "Andrew" <jordan...sol-3.co.uk> wrote:
      >
      >Thanks again Monte, the o/s is Windows 98, Err.LastDllError returns 0 with
      >the original .exe, but returns 11 with the newly compiled but unaltered
      source
      >code.exe.
      >
      >I cant find any documentation to explain the error code.
      >
      >Any explanation would be gratefully recieved.
      >
      >"Monte Hansen" <monte...nospam.com> wrote:
      >>
      >>What's Err.LastDllError? What's the O/S?
      >>
      >>Do these exceptions apply?:
      >>--------
      >>Windows 95/98/Me: If you are using LoadLibraryEx to load a module that
      contains
      >>a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      >>fails. If you are attempting to load a 16-bit DLL directly from 32-bit
      code,
      >>LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      >>version is greater than 4.0, LoadLibraryEx fails. If your DllMain function
      >>tries to call the Unicode version of a Win32 function, LoadLibraryEx fails.
      >>
      >>
      >>Also, FYI, I would still use the Ex version as a matter of practice :)
      >>
      >>++++++++++++++++++++
      >>Monte Hansen
      >>http://KillerVB.com
      >>++++++++++++++++++++
      >>
      >>
      >>"Andrew" <jordan...sol-3.co.uk> wrote:
      >>>
      >>>Thanks Monte, but I am getting the same results with LoadLibraryEx and
      >the
      >>>absolute path.
      >>>
      >>>"Monte Hansen" <monte...nospam.com> wrote:
      >>>>Andrew, I would suggest first that you use the LoadLibraryEx function
      >with
      >>>>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >>>>
      >>>>Next I would question if the function can even find the file; perhaps
      >try
      >>>an
      >>>>absolute path first, then worry about the relative path spec once you
      >get
      >>>it
      >>>>working.
      >>>>
      >>>>Hope this helps.
      >>>>
      >>>>++++++++++++++++++++
      >>>>Monte Hansen
      >>>>http://KillerVB.com
      >>>>++++++++++++++++++++
      >>>>
      >>>>"Andrew" <jordan...sol-3.co.uk> wrote in message
      >>>>news:3b8cd18a$1...news.dev-archive.com...
      >>>>>
      >>>>> I recently downloaded a sample app that resizes a background image
      on
      >>>a
      >>>>MDI
      >>>>> form. The app works fine but if I modify it I cant get it to work in
      >>the
      >>>>> IDE, however the .exe works fine.
      >>>>>
      >>>>> The sample uses the following code to get resources from the compiled
      >>>app
      >>>>> while running in the IDE.
      >>>>>
      >>>>> If RunningInIde() Then
      >>>>> hModule = LoadLibrary("PMDIBackground.exe")
      >>>>> Else
      >>>>> hModule = App.hInstance
      >>>>> End If
      >>>>>
      >>>>> I think the problem is something to do with compiling the .exe as
      >>>>LoadLibrary
      >>>>> only works when pointed at the original .exe. and even if I create
      a
      >>new
      >>>>> exe from the original unmodified code it fails.
      >>>>>
      >>>>> I have tried all the different options on the compile tab except advanced
      >>>>> options to no avail.
      >>>>>
      >>>>> I have never compile anything with a resource file before, could I
      be
      >>>>missing
      >>>>> something there?
      >>>>>
      >>>>> Thanks in advance.
      >>>>
      >>>>
      >>>
      >>
      >

      montehansen | Sun, 11 Nov 2007 18:57:09 GMT |

    11. Try VC++ Error Lookup utility
      -Sachin
      "Andrew" <jordan...sol-3.co.uk> wrote in message
      news:3b8d4b7f$1...news.dev-archive.com...
      >
      > Thanks again Monte, the o/s is Windows 98, Err.LastDllError returns 0 with
      > the original .exe, but returns 11 with the newly compiled but unaltered
      source
      > code.exe.
      >
      > I cant find any documentation to explain the error code.
      >
      > Any explanation would be gratefully recieved.
      >
      > "Monte Hansen" <monte...nospam.com> wrote:
      > >
      > >What's Err.LastDllError? What's the O/S?
      > >
      > >Do these exceptions apply?:
      > >--------
      > >Windows 95/98/Me: If you are using LoadLibraryEx to load a module that
      contains
      > >a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      > >fails. If you are attempting to load a 16-bit DLL directly from 32-bit
      code,
      > >LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      > >version is greater than 4.0, LoadLibraryEx fails. If your DllMain
      function
      > >tries to call the Unicode version of a Win32 function, LoadLibraryEx
      fails.
      > >
      > >
      > >Also, FYI, I would still use the Ex version as a matter of practice :)
      > >
      > >++++++++++++++++++++
      > >Monte Hansen
      > >http://KillerVB.com
      > >++++++++++++++++++++
      > >
      > >
      > >"Andrew" <jordan...sol-3.co.uk> wrote:
      > >>
      > >>Thanks Monte, but I am getting the same results with LoadLibraryEx and
      > the
      > >>absolute path.
      > >>
      > >>"Monte Hansen" <monte...nospam.com> wrote:
      > >>>Andrew, I would suggest first that you use the LoadLibraryEx function
      > with
      > >>>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      > >>>
      > >>>Next I would question if the function can even find the file; perhaps
      > try
      > >>an
      > >>>absolute path first, then worry about the relative path spec once you
      > get
      > >>it
      > >>>working.
      > >>>
      > >>>Hope this helps.
      > >>>
      > >>>++++++++++++++++++++
      > >>>Monte Hansen
      > >>>http://KillerVB.com
      > >>>++++++++++++++++++++
      > >>>
      > >>>"Andrew" <jordan...sol-3.co.uk> wrote in message
      > >>>news:3b8cd18a$1...news.dev-archive.com...
      > >>>>
      > >>>> I recently downloaded a sample app that resizes a background image on
      > >>a
      > >>>MDI
      > >>>> form. The app works fine but if I modify it I cant get it to work in
      > >the
      > >>>> IDE, however the .exe works fine.
      > >>>>
      > >>>> The sample uses the following code to get resources from the compiled
      > >>app
      > >>>> while running in the IDE.
      > >>>>
      > >>>> If RunningInIde() Then
      > >>>> hModule = LoadLibrary("PMDIBackground.exe")
      > >>>> Else
      > >>>> hModule = App.hInstance
      > >>>> End If
      > >>>>
      > >>>> I think the problem is something to do with compiling the .exe as
      > >>>LoadLibrary
      > >>>> only works when pointed at the original .exe. and even if I create a
      > >new
      > >>>> exe from the original unmodified code it fails.
      > >>>>
      > >>>> I have tried all the different options on the compile tab except
      advanced
      > >>>> options to no avail.
      > >>>>
      > >>>> I have never compile anything with a resource file before, could I be
      > >>>missing
      > >>>> something there?
      > >>>>
      > >>>> Thanks in advance.
      > >>>
      > >>>
      > >>
      > >
      >

      sachin | Sun, 11 Nov 2007 18:58:04 GMT |

    12. Try VC++ Error Lookup utility
      -Sachin
      "Andrew" <jordan...sol-3.co.uk> wrote in message
      news:3b8d4b7f$1...news.dev-archive.com...
      >
      > Thanks again Monte, the o/s is Windows 98, Err.LastDllError returns 0 with
      > the original .exe, but returns 11 with the newly compiled but unaltered
      source
      > code.exe.
      >
      > I cant find any documentation to explain the error code.
      >
      > Any explanation would be gratefully recieved.
      >
      > "Monte Hansen" <monte...nospam.com> wrote:
      > >
      > >What's Err.LastDllError? What's the O/S?
      > >
      > >Do these exceptions apply?:
      > >--------
      > >Windows 95/98/Me: If you are using LoadLibraryEx to load a module that
      contains
      > >a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      > >fails. If you are attempting to load a 16-bit DLL directly from 32-bit
      code,
      > >LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      > >version is greater than 4.0, LoadLibraryEx fails. If your DllMain
      function
      > >tries to call the Unicode version of a Win32 function, LoadLibraryEx
      fails.
      > >
      > >
      > >Also, FYI, I would still use the Ex version as a matter of practice :)
      > >
      > >++++++++++++++++++++
      > >Monte Hansen
      > >http://KillerVB.com
      > >++++++++++++++++++++
      > >
      > >
      > >"Andrew" <jordan...sol-3.co.uk> wrote:
      > >>
      > >>Thanks Monte, but I am getting the same results with LoadLibraryEx and
      > the
      > >>absolute path.
      > >>
      > >>"Monte Hansen" <monte...nospam.com> wrote:
      > >>>Andrew, I would suggest first that you use the LoadLibraryEx function
      > with
      > >>>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      > >>>
      > >>>Next I would question if the function can even find the file; perhaps
      > try
      > >>an
      > >>>absolute path first, then worry about the relative path spec once you
      > get
      > >>it
      > >>>working.
      > >>>
      > >>>Hope this helps.
      > >>>
      > >>>++++++++++++++++++++
      > >>>Monte Hansen
      > >>>http://KillerVB.com
      > >>>++++++++++++++++++++
      > >>>
      > >>>"Andrew" <jordan...sol-3.co.uk> wrote in message
      > >>>news:3b8cd18a$1...news.dev-archive.com...
      > >>>>
      > >>>> I recently downloaded a sample app that resizes a background image on
      > >>a
      > >>>MDI
      > >>>> form. The app works fine but if I modify it I cant get it to work in
      > >the
      > >>>> IDE, however the .exe works fine.
      > >>>>
      > >>>> The sample uses the following code to get resources from the compiled
      > >>app
      > >>>> while running in the IDE.
      > >>>>
      > >>>> If RunningInIde() Then
      > >>>> hModule = LoadLibrary("PMDIBackground.exe")
      > >>>> Else
      > >>>> hModule = App.hInstance
      > >>>> End If
      > >>>>
      > >>>> I think the problem is something to do with compiling the .exe as
      > >>>LoadLibrary
      > >>>> only works when pointed at the original .exe. and even if I create a
      > >new
      > >>>> exe from the original unmodified code it fails.
      > >>>>
      > >>>> I have tried all the different options on the compile tab except
      advanced
      > >>>> options to no avail.
      > >>>>
      > >>>> I have never compile anything with a resource file before, could I be
      > >>>missing
      > >>>> something there?
      > >>>>
      > >>>> Thanks in advance.
      > >>>
      > >>>
      > >>
      > >
      >

      sachin | Sun, 11 Nov 2007 18:59:13 GMT |

    13. Thanks ,but I am still getting nowhere with this. The .exe contains two resources
      with IDs of 200 and 201, which should be OK according to the documentation,
      or is there something about resource IDs that I dont understand (probably
      many things).
      What really baffles me is how simply recompiling the original source on my
      machine can be causing this error.

      "Monte Hansen" <monte...nospam.com> wrote:
      >
      >In your "Microsoft Visual Studio 6.0\Microsoft Visual Studio 6.0 Tools"
      menu,
      >you will find a tool called "Error Lookup". Punch in "11" and you get the
      >error description of:
      >
      >>An attempt was made to load a program with an incorrect format.
      >
      >Your problem is documented in the SDK, and in this article:
      >PRB: Cannot Load Module with Resource ID Greater Than 32767 (0x7FFF)
      >Q137248
      >
      >++++++++++++++++++++
      >Monte Hansen
      >http://KillerVB.com
      >++++++++++++++++++++
      >
      >
      >"Andrew" <jordan...sol-3.co.uk> wrote:
      >>
      >>Thanks again Monte, the o/s is Windows 98, Err.LastDllError returns 0 with
      >>the original .exe, but returns 11 with the newly compiled but unaltered
      >source
      >>code.exe.
      >>
      >>I cant find any documentation to explain the error code.
      >>
      >>Any explanation would be gratefully recieved.
      >>
      >>"Monte Hansen" <monte...nospam.com> wrote:
      >>>
      >>>What's Err.LastDllError? What's the O/S?
      >>>
      >>>Do these exceptions apply?:
      >>>--------
      >>>Windows 95/98/Me: If you are using LoadLibraryEx to load a module that
      >contains
      >>>a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      >>>fails. If you are attempting to load a 16-bit DLL directly from 32-bit
      >code,
      >>>LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      >>>version is greater than 4.0, LoadLibraryEx fails. If your DllMain function
      >>>tries to call the Unicode version of a Win32 function, LoadLibraryEx fails.
      >>>
      >>>
      >>>Also, FYI, I would still use the Ex version as a matter of practice :)
      >>>
      >>>++++++++++++++++++++
      >>>Monte Hansen
      >>>http://KillerVB.com
      >>>++++++++++++++++++++
      >>>
      >>>
      >>>"Andrew" <jordan...sol-3.co.uk> wrote:
      >>>>
      >>>>Thanks Monte, but I am getting the same results with LoadLibraryEx and
      >>the
      >>>>absolute path.
      >>>>
      >>>>"Monte Hansen" <monte...nospam.com> wrote:
      >>>>>Andrew, I would suggest first that you use the LoadLibraryEx function
      >>with
      >>>>>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >>>>>
      >>>>>Next I would question if the function can even find the file; perhaps
      >>try
      >>>>an
      >>>>>absolute path first, then worry about the relative path spec once you
      >>get
      >>>>it
      >>>>>working.
      >>>>>
      >>>>>Hope this helps.
      >>>>>
      >>>>>++++++++++++++++++++
      >>>>>Monte Hansen
      >>>>>http://KillerVB.com
      >>>>>++++++++++++++++++++
      >>>>>
      >>>>>"Andrew" <jordan...sol-3.co.uk> wrote in message
      >>>>>news:3b8cd18a$1...news.dev-archive.com...
      >>>>>>
      >>>>>> I recently downloaded a sample app that resizes a background image
      >on
      >>>>a
      >>>>>MDI
      >>>>>> form. The app works fine but if I modify it I cant get it to work
      in
      >>>the
      >>>>>> IDE, however the .exe works fine.
      >>>>>>
      >>>>>> The sample uses the following code to get resources from the compiled
      >>>>app
      >>>>>> while running in the IDE.
      >>>>>>
      >>>>>> If RunningInIde() Then
      >>>>>> hModule = LoadLibrary("PMDIBackground.exe")
      >>>>>> Else
      >>>>>> hModule = App.hInstance
      >>>>>> End If
      >>>>>>
      >>>>>> I think the problem is something to do with compiling the .exe as
      >>>>>LoadLibrary
      >>>>>> only works when pointed at the original .exe. and even if I create
      >a
      >>>new
      >>>>>> exe from the original unmodified code it fails.
      >>>>>>
      >>>>>> I have tried all the different options on the compile tab except advanced
      >>>>>> options to no avail.
      >>>>>>
      >>>>>> I have never compile anything with a resource file before, could I
      >be
      >>>>>missing
      >>>>>> something there?
      >>>>>>
      >>>>>> Thanks in advance.
      >>>>>
      >>>>>
      >>>>
      >>>
      >>
      >

      andrew | Sun, 11 Nov 2007 19:00:14 GMT |

    14. Thanks ,but I am still getting nowhere with this. The .exe contains two resources
      with IDs of 200 and 201, which should be OK according to the documentation,
      or is there something about resource IDs that I dont understand (probably
      many things).
      What really baffles me is how simply recompiling the original source on my
      machine can be causing this error.

      "Monte Hansen" <monte...nospam.com> wrote:
      >
      >In your "Microsoft Visual Studio 6.0\Microsoft Visual Studio 6.0 Tools"
      menu,
      >you will find a tool called "Error Lookup". Punch in "11" and you get the
      >error description of:
      >
      >>An attempt was made to load a program with an incorrect format.
      >
      >Your problem is documented in the SDK, and in this article:
      >PRB: Cannot Load Module with Resource ID Greater Than 32767 (0x7FFF)
      >Q137248
      >
      >++++++++++++++++++++
      >Monte Hansen
      >http://KillerVB.com
      >++++++++++++++++++++
      >
      >
      >"Andrew" <jordan...sol-3.co.uk> wrote:
      >>
      >>Thanks again Monte, the o/s is Windows 98, Err.LastDllError returns 0 with
      >>the original .exe, but returns 11 with the newly compiled but unaltered
      >source
      >>code.exe.
      >>
      >>I cant find any documentation to explain the error code.
      >>
      >>Any explanation would be gratefully recieved.
      >>
      >>"Monte Hansen" <monte...nospam.com> wrote:
      >>>
      >>>What's Err.LastDllError? What's the O/S?
      >>>
      >>>Do these exceptions apply?:
      >>>--------
      >>>Windows 95/98/Me: If you are using LoadLibraryEx to load a module that
      >contains
      >>>a resource whose numeric identifier is greater than 0x7FFF, LoadLibraryEx
      >>>fails. If you are attempting to load a 16-bit DLL directly from 32-bit
      >code,
      >>>LoadLibraryEx fails. If you are attempting to load a DLL whose subsystem
      >>>version is greater than 4.0, LoadLibraryEx fails. If your DllMain function
      >>>tries to call the Unicode version of a Win32 function, LoadLibraryEx fails.
      >>>
      >>>
      >>>Also, FYI, I would still use the Ex version as a matter of practice :)
      >>>
      >>>++++++++++++++++++++
      >>>Monte Hansen
      >>>http://KillerVB.com
      >>>++++++++++++++++++++
      >>>
      >>>
      >>>"Andrew" <jordan...sol-3.co.uk> wrote:
      >>>>
      >>>>Thanks Monte, but I am getting the same results with LoadLibraryEx and
      >>the
      >>>>absolute path.
      >>>>
      >>>>"Monte Hansen" <monte...nospam.com> wrote:
      >>>>>Andrew, I would suggest first that you use the LoadLibraryEx function
      >>with
      >>>>>the DONT_RESOLVE_DLL_REFERENCES flag, for resource loading.
      >>>>>
      >>>>>Next I would question if the function can even find the file; perhaps
      >>try
      >>>>an
      >>>>>absolute path first, then worry about the relative path spec once you
      >>get
      >>>>it
      >>>>>working.
      >>>>>
      >>>>>Hope this helps.
      >>>>>
      >>>>>++++++++++++++++++++
      >>>>>Monte Hansen
      >>>>>http://KillerVB.com
      >>>>>++++++++++++++++++++
      >>>>>
      >>>>>"Andrew" <jordan...sol-3.co.uk> wrote in message
      >>>>>news:3b8cd18a$1...news.dev-archive.com...
      >>>>>>
      >>>>>> I recently downloaded a sample app that resizes a background image
      >on
      >>>>a
      >>>>>MDI
      >>>>>> form. The app works fine but if I modify it I cant get it to work
      in
      >>>the
      >>>>>> IDE, however the .exe works fine.
      >>>>>>
      >>>>>> The sample uses the following code to get resources from the compiled
      >>>>app
      >>>>>> while running in the IDE.
      >>>>>>
      >>>>>> If RunningInIde() Then
      >>>>>> hModule = LoadLibrary("PMDIBackground.exe")
      >>>>>> Else
      >>>>>> hModule = App.hInstance
      >>>>>> End If
      >>>>>>
      >>>>>> I think the problem is something to do with compiling the .exe as
      >>>>>LoadLibrary
      >>>>>> only works when pointed at the original .exe. and even if I create
      >a
      >>>new
      >>>>>> exe from the original unmodified code it fails.
      >>>>>>
      >>>>>> I have tried all the different options on the compile tab except advanced
      >>>>>> options to no avail.
      >>>>>>
      >>>>>> I have never compile anything with a resource file before, could I
      >be
      >>>>>missing
      >>>>>> something there?
      >>>>>>
      >>>>>> Thanks in advance.
      >>>>>
      >>>>>
      >>>>
      >>>
      >>
      >

      andrew | Sun, 11 Nov 2007 19:01:08 GMT |

  • Microsoft Visual Basic Questions

    • GroupWise Mail

      He you guys,I have a programm that put's automatic appointments in a persons GroupWise Calander...

      By phoney

    • Remote computer shutdown (power off)

      hi thereI need to shut down w2k machine remotely. I know, that I can use InitiateSystemShutdown API ...

      By lollla

    • STMP Anyone?

      I am looking for a way to access information returned from an SNMP agent (common agent UPS's ru...

      By aries

    • MDI Picture

      Hello, I'm looking for away to change the mdi picture of a this a online multiplayer game that ...

      By hbb

    • Installshield Express Customer Information

      When setting up an install, you can chose to prompt the user for customer information. Once the prog...

      By vitani

    • ASP

      [Originally posted by Kirankumar]How can we get data from database into WORD document using ASP or X...

      By anonymous

    • no boddy their to solve it

      hi all, is their anybody who can tell me how to logg off the person in the lan.if possib...

      By vbkida

    • There, Their and Theyre

      Sorry to be the grammar police, but there seems to be a lot of confusion about which of three words ...

      By cafeenman, 41 Comments

    • button and events

      Given a dialog with several buttons. Default behavior is when user press arrow keys to move the focu...

      By vin, 1 Comments

    • MSChart how to print

      [Originally posted by Ron Weller] I have created a graph of my data on the MSChartcontrol. Is there ...

      By anonymous, 3 Comments

    • I get a simple error, but dont know how to fix

      This is my codeOption ExplicitPrivate Sub TerminateProcess(app_exe As String) Dim Process As Obje...

      By gunner54, 7 Comments

    • Virus? Please read

      [Originally posted by Mike Lyons]This is just a heads up to everyone...This morning my spam filter t...

      By anonymous, 1 Comments

    • Virus??

      Hi FriendsSome program in my computer is attempting to connect the internet. I think its a virus. Is...

      By abhilashdas, 4 Comments

    • Stock Problem

      am developing Application VB and Accessi have 3 tablesItem_desc_localItem_desc_outwardStock_masterIn...

      By vaishali, 11 Comments

    • Virus Protection

      How would you rate yor virus protection (or how scared are you! hehe)...

      By chenko, 9 Comments