My problem is with passing "\\\\.\\readios" from VB6 to C DLL. I can call the Function from VB6 and it returns the file handle, but only if I supply the data in the DLL code.
I need to replace *The Problem* in the C code with a declared variable that will accomplish the same as the ' const char* ' declaration in the code. Replacing the *The Problem* with the ' const char* ' declaration does not solve the problem.
Thanks in advance for helping,
Servo
Visual Basic 6.0:
Option Explicit Private Declare Function GetDriverHandle _ Lib "driverid.dll" ( _ ByVal ServiceName As String) As Long Private Sub Form_Load() Dim Service As String Service = "\\\\.\\readios" With DRO .Text = GetDriverHandle(Service) .SelStart = 0 .SelLength = Len(.Text) .SelColor = &HFF00& .SelLength = 0 End With End Sub
Visual C 6.0:
#include <stdio.h>
#include <windows.h>
BOOL APIENTRY DllMain(HANDLE hModule,DWORD dwMission,LPVOID lpReserved)
{
switch (dwMission)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH: break;
}
return TRUE;
}
HANDLE hFile;
HANDLE __stdcall GetDriverHandle(*The Problem*)
{
const char* ServiceName="\\\\.\\readios";
hFile=CreateFile
(
ServiceName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
return hFile;
}

New Topic/Question
Reply




MultiQuote






|