Search code examples
windows-10vb6winsock

How to compile Winsock Control 6.0 on VB6 in Windows 10?


When trying to compile in the "Winsock Control" component on Windows 10, I get this error:

mswinsck.ocx could not be loaded

image

Notably, I have installed VB6 SP6, and with SP6 it works great on Windows 8.1 and Windows 7, but it won't compile on Windows 10.

Also notably, the compiled .exe, when compiled from Win7/8, has no problem loading ws2_32.dll. It's just the compiling step that doesn't work on Win10.

Running Dependency Walker, depends.exe suggests mswinsck.ocx can't be loaded because it's depending on API-MS-WIN-CORE-SYNCH-L1-2-0.DLL and API-MS-WIN-CORE-PROFILE-L1-1-0.DLL and API-MS-WIN-CORE-PROCESSTHREADS-L1-1-0.DLL and a bunch of other DLLs with similar names (I think these DLLs have something to do with SysWOW64), which can't be found:

image

Does anyone know how to compile in "Winsock Control" in VB6 on Win10?

(Also notably, it seems the MSFlexGrid component is un-compilable on Win10 in a similar fashion, but this question is about the WinSock control, not MSFlexGrid).

EDIT: additional info: I have installed "VB6 Service Pack 6", VB version is "Version 9782 VBA retail 6.0.9782", and the version on the mswinsck.ocx file itself is 6.1.97.82 (and thanks to the comments, I know a newer one exists: 6.1.98.16)


Solution

  • I have run into this problem often on Windows 10 machines and resolved it by unregistering and re-registering each OCX using an elevated Command Prompt:

    1. Open a Command Prompt window from the Start Menu by right-clicking it and choosing "Run as administrator". It is important that your Command Prompt window is titled "Administrator: Command Prompt".
    2. Go to SysWOW64 folder by typing cd \Windows\SysWOW64
    3. Unregister OCX by typing regsvr32 -u mswinsck.ocx
    4. Re-register OCX by typing regsvr32 mswinsck.ocx

    That usually fixes the problem.

    If you use Visual Studio Installer 1.1 to deploy applications, you will probably have the same issue on Windows 10 systems you deploy to. The installer doesn't seem to properly register files. If you use Visual Studio 2019 and the Setup extension, that will build an installer that properly registers the OCX, in my experience.