Results 1 to 24 of 24

Thread: [RESOLVED] VB6 EXE does not work, but runs from VB6 IDE

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2016
    Posts
    51

    [RESOLVED] VB6 EXE does not work, but runs from VB6 IDE

    Hi,

    my code in IDE can run , but build exe can't run,the following code add msgbox then can run ,why?

    (mk_xxxx were dllimport dll file)

    Code:
    Private Sub btnDARK_Click()
        
        Dim result As Boolean
        
        result = mk_Msr_AutoDarkCtrl(id, 0)
    
        ' When I put this MsgBox "OK" , it works......
    
        result = mk_Msr_SetExpMode(id, 0)
        result = mk_Msr_SetMaxExpTime(id, 500000)
        result = mk_senr_Msr_Dark(id)
        
        If result Then
            Label6.Caption = "Dark : OK"
        Else
            Label6.Caption = "Dark : NG"
        End If
        
    End Sub
    Last edited by kevin651212; Oct 28th, 2020 at 01:21 AM.

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,970

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Maybe it needs some time to complete?

    Can you explain what this is about?
    mk_Msr... etc etc

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2016
    Posts
    51

    Re: VB6 EXE does not work, but runs from VB6 IDE

    VS2017 can run , but vb6 does not work

    The dll file is from the manufacturer

    The attached file is vb6 dll。

    in vb6 module:
    Code:
    Option Explicit
    
    Const dllPath As String = "mkusb.dll"
    
    
    Declare Function mk_Init Lib "mkusb.dll" Alias "_mk_Init@8" (ByVal isMonitor As Long, ByVal msec As Long) As Boolean
    Declare Sub mk_Close Lib "mkusb.dll" Alias "_mk_Close@0" ()
    Declare Function mk_version Lib "mkusb.dll" Alias "_mk_version@0" () As Integer
    Declare Function mk_IsUpdate Lib "mkusb.dll" Alias "_mk_IsUpdate@0" () As Boolean
    Declare Function mk_FindFirst Lib "mkusb.dll" Alias "_mk_FindFirst@4" (ByVal name As String) As Boolean
    Declare Function mk_FindNext Lib "mkusb.dll" Alias "_mk_FindNext@4" (ByVal name As String) As Boolean
    Declare Function mk_FindClose Lib "mkusb.dll" Alias "_mk_FindClose@0" () As Boolean
    
    Declare Function mk_GetOptSnByName Lib "mkusb.dll" Alias "_mk_GetOptSnByName@8" (ByVal name As String, ByVal sn As String) As Long
    Declare Function mk_OpenSpDev Lib "mkusb.dll" Alias "_mk_OpenSpDev@4" (ByVal name As String) As Long
    Declare Function mk_OpenSpDev_OptSn Lib "mkusb.dll" Alias "_mk_OpenSpDev_OptSn@4" (ByVal name As String) As Long
    Declare Function mk_CloseSpDev Lib "mkusb.dll" Alias "_mk_CloseSpDev@4" (ByVal i As Integer) As Boolean
    Declare Function mk_GetDeviceCnt Lib "mkusb.dll" Alias "_mk_GetDeviceCnt@0" () As Integer
    Declare Function mk_SpDevScan Lib "mkusb.dll" Alias "_mk_SpDevScan@0" () As Boolean
    Declare Function mk_Info_Get Lib "mkusb.dll" Alias "_mk_Info_Get@12" (ByVal i As Integer, ByVal id As Integer, ByVal str_info As String) As Boolean
    
    Declare Function mk_Msr_AutoDarkCtrl Lib "mkusb.dll" Alias "_mk_Msr_AutoDarkCtrl@8" (ByVal i As Integer, ByVal ctl As Long) As Boolean
    Declare Function mk_Msr_SetMaxExpTime Lib "mkusb.dll" Alias "_mk_Msr_SetMaxExpTime@8" (ByVal i As Integer, ByVal maxtime As Long) As Boolean
    Declare Function mk_Msr_SetExpMode Lib "mkusb.dll" Alias "_mk_Msr_SetExpMode@8" (ByVal i As Integer, ByVal mode As Long) As Boolean
    Declare Function mk_Msr_Capture Lib "mkusb.dll" Alias "_mk_Msr_Capture@12" (ByVal i As Integer, ByVal isAuto As Integer, ByVal exptime As Integer) As Boolean
    Declare Function mk_Msr_Dark Lib "mkusb.dll" Alias "_mk_Msr_Dark@4" (ByVal i As Integer) As Boolean
    
    Declare Function mk_GetData Lib "mkusb.dll" Alias "_mk_GetData@12" (ByVal i As Integer, ByVal v As Integer, ByRef data As Single) As Boolean
    Declare Function mk_GetSpectrum Lib "mkusb.dll" Alias "_mk_GetSpectrum@16" (ByVal i As Integer, ByVal str As Integer, ByVal stp As Integer, ByRef data() As Single) As Boolean
    Declare Function mk_GetMicroMole Lib "mkusb.dll" Alias "_mk_GetMicroMole@16" (ByVal i As Integer, ByVal str As Integer, ByVal stp As Integer, ByRef data() As Single) As Boolean
    Declare Function mk_GetOptSn Lib "mkusb.dll" Alias "_mk_GetOptSn@8" (ByVal i As Integer, ByVal sn As String) As Boolean
    Declare Function mk_GetLightStrnegth Lib "mkusb.dll" Alias "_mk_GetLightStrnegth@4" (ByVal i As Integer) As Integer
    
    Declare Function mk_Peri_GetTemp Lib "mkusb.dll" Alias "_mk_Peri_GetTemp@8" (ByVal i As Integer, ByRef data As Single) As Boolean
    Declare Function mk_Peri_SetLCD Lib "mkusb.dll" Alias "_mk_Peri_SetLCD@8" (ByVal i As Integer, ByVal data As Long) As Boolean
    Declare Function mk_Peri_KeyEnable Lib "mkusb.dll" Alias "_mk_Peri_KeyEnable@4" (ByVal i As Integer) As Boolean
    Declare Function mk_Peri_KeyDisable Lib "mkusb.dll" Alias "_mk_Peri_KeyDisable@4" (ByVal i As Integer) As Boolean
    Declare Function mk_Peri_KeyClear Lib "mkusb.dll" Alias "_mk_Peri_KeyClear@4" (ByVal i As Integer) As Boolean
    Declare Function mk_Peri_KeyGet Lib "mkusb.dll" Alias "_mk_Peri_KeyGet@4" (ByVal i As Integer) As Boolean
    
    
    Declare Function mk_flk_Dark Lib "mkusb.dll" Alias "_mk_flk_Dark@4" (ByVal i As Integer) As Boolean
    Declare Function mk_flk_SetPara Lib "mkusb.dll" Alias "_mk_flk_SetPara@20" (ByVal i As Integer, ByVal sample_num As Integer, ByVal sampel_freq As Integer, ByVal fir_num As Integer, ByVal fir_cutfreq As Integer) As Boolean
    Declare Function mk_flk_Capture Lib "mkusb.dll" Alias "_mk_flk_Capture@16" (ByVal i As Integer, ByVal isAutoGain As Long, ByVal gain As Long, ByVal enable_fir As Long) As Boolean
    Declare Function mk_flk_GetData Lib "mkusb.dll" Alias "_mk_flk_GetData@12" (ByVal i As Integer, ByVal v As Integer, ByRef data As Single) As Boolean
    Declare Function mk_flk_GetTimeDomainWaveform Lib "mkusb.dll" Alias "_mk_flk_GetTimeDomainWaveform@12" (ByVal i As Integer, ByVal size As Integer, ByRef data() As Single) As Boolean
    Declare Function mk_flk_GetFreqDomainWaveform Lib "mkusb.dll" Alias "_mk_flk_GetFreqDomainWaveform@16" (ByVal i As Integer, ByVal size As Integer, ByRef freq() As Single, ByRef data() As Single) As Boolean
    
    Declare Function mk_senr_Msr_Capture Lib "mkusb.dll" Alias "_mk_senr_Msr_Capture@12" (ByVal i As Integer, ByVal isAuto As Integer, ByVal exptime As Integer) As Boolean
    Declare Function mk_senr_Msr_Dark Lib "mkusb.dll" Alias "_mk_senr_Msr_Dark@4" (ByVal i As Integer) As Boolean
    Declare Function mk_senr_GetPeakSpRaw Lib "mkusb.dll" Alias "_mk_senr_GetPeakSpRaw@12" (ByVal i As Integer, ByVal exptime As Integer, ByRef data As Long) As Boolean
    
    Declare Function mk_Msr_SetCorrMatrixCH Lib "mkusb.dll" Alias "_mk_Msr_SetCorrMatrixCH@8" (ByVal i As Integer, ByVal ch As Integer) As Boolean
    Declare Function mk_Msr_GetCorrMatrixPara Lib "mkusb.dll" Alias "_mk_Msr_GetCorrMatrixPara@16" (ByVal i As Integer, ByVal ch As Integer, ByVal name As String, ByRef data() As Double) As Boolean
    Declare Function mk_Msr_SetCorrMatrixPara Lib "mkusb.dll" Alias "_mk_Msr_SetCorrMatrixPara@16" (ByVal i As Integer, ByVal ch As Integer, ByVal name As String, ByRef data() As Double) As Boolean
    Declare Function mk_Msr_GenerateCorrMatrix Lib "mkusb.dll" Alias "_mk_Msr_GenerateCorrMatrix@20" (ByRef Ref() As Double, ByRef mes() As Double, ByVal l As Integer, ByRef corr() As Double, ByVal colorspace As Integer) As Boolean
    
    Declare Function mk_sflk_Dark Lib "mkusb.dll" Alias "_mk_sflk_Dark@12" (ByVal i As Integer, ByVal uexptime As Integer, ByVal sampletime As Integer) As Boolean
    Declare Function mk_sflk_SetPara Lib "mkusb.dll" Alias "_mk_sflk_SetPara@20" (ByVal i As Integer, ByVal sample_num As Integer, ByVal sample_freq As Integer, ByVal fir_num As Integer, ByVal fir_cutfreq As Integer) As Boolean
    Declare Function mk_sflk_Capture Lib "mkusb.dll" Alias "_mk_sflk_Capture@12" (ByVal i As Integer, ByVal uexptime As Long, ByVal enable_fir As Long) As Boolean
    Declare Function mk_sflk_CaptureRaw Lib "mkusb.dll" Alias "_mk_sflk_CaptureRaw@12" (ByVal i As Integer, ByVal uexptime As Integer, ByRef ptr As Long) As Boolean
    Declare Function mk_sflk_GetData Lib "mkusb.dll" Alias "_mk_sflk_GetData@12" (ByVal i As Integer, ByVal v As Integer, ByRef data As Single) As Boolean
    
    Declare Function mk_Msr_SetLightMode Lib "mkusb.dll" Alias "_mk_Msr_SetLightMode@12" (ByVal i As Integer, ByVal mode As Long, ByVal freq As Long) As Boolean
    Declare Function mk_Msr_SetLightModeFlt Lib "mkusb.dll" Alias "_mk_Msr_SetLightModeFlt@12" (ByVal i As Integer, ByVal mode As Long, ByVal freq As Long) As Boolean
    Declare Function mk_Msr_SetLightMode_CycleNumber Lib "mkusb.dll" Alias "_mk_Msr_SetLightMode_CycleNumber@8" (ByVal i As Integer, ByVal cycnumber As Long) As Boolean
    Declare Function mk_Msr_SetLightMode_LCyc_LeastSampleNumber Lib "mkusb.dll" Alias "_mk_Msr_SetLightMode_LCyc_LeastSampleNumber@8" (ByVal i As Integer, ByVal num As Long) As Boolean
    Declare Function mk_Msr_SetLightMode_PreScanPara Lib "mkusb.dll" Alias "_mk_Msr_SetLightMode_PreScanPara@12" (ByVal i As Integer, ByVal time As Single, ByVal level As Single) As Boolean
    Declare Function mk_Msr_SetLightMode_AutoExp Lib "mkusb.dll" Alias "_mk_Msr_SetLightMode_AutoExp@8" (ByVal i As Integer, ByVal itime As Long) As Boolean
    Declare Function mk_Msr_SetLowLightFixedValue Lib "mkusb.dll" Alias "_mk_Msr_SetLowLightFixedValue@12" (ByVal i As Integer, ByVal ctrl As Long, ByVal value As Single) As Boolean
    
    
    Declare Function mk_ManualScan Lib "mkusb.dll" Alias "_mk_ManualScan@0" () As Integer
    
    
    Public Const DATA_CLR_BASE As Integer = &H0
    Public Const DATA_CRI_BASE As Integer = &H1000
    Public Const DATA_GAI_BASE As Integer = &H2000
    Public Const DATA_CQS_BASE As Integer = &H3000
    Public Const DATA_TM30_BASE As Integer = &H5000
    Public Const DATA_TLCI_BASE As Integer = &H4000
    Public Const DATA_OTH_BASE As Integer = &H8000
    
    Public Const DATA_CIE1931_x As Integer = (DATA_CLR_BASE Or &H1)
    Public Const DATA_CIE1931_y As Integer = (DATA_CLR_BASE Or &H2)
    Public Const DATA_CIE_X As Integer = (DATA_CLR_BASE Or &H3)
    Public Const DATA_CIE_Y As Integer = (DATA_CLR_BASE Or &H4)
    Public Const DATA_CIE_Z As Integer = (DATA_CLR_BASE Or &H5)
    Public Const DATA_CIE1964_x10 As Integer = (DATA_CLR_BASE Or &H6)
    Public Const DATA_CIE1964_y10 As Integer = (DATA_CLR_BASE Or &H7)
    Public Const DATA_CIE_X10 As Integer = (DATA_CLR_BASE Or &H8)
    Public Const DATA_CIE_Y10 As Integer = (DATA_CLR_BASE Or &H9)
    Public Const DATA_CIE_Z10 As Integer = (DATA_CLR_BASE Or &HA)
    
    Public Const DATA_CIE1976_up As Integer = (DATA_CLR_BASE Or &H11)
    Public Const DATA_CIE1976_vp As Integer = (DATA_CLR_BASE Or &H12)
    Public Const DATA_CIE1976_up10 As Integer = (DATA_CLR_BASE Or &H13)
    Public Const DATA_CIE1976_vp10 As Integer = (DATA_CLR_BASE Or &H14)
    Public Const DATA_CIE1960_du As Integer = (DATA_CLR_BASE Or &H21)
    Public Const DATA_CIE1960_dv As Integer = (DATA_CLR_BASE Or &H22)
    Public Const DATA_LUX As Integer = (DATA_CLR_BASE Or &H101)
    Public Const DATA_L As Integer = (DATA_CLR_BASE Or &H101)
    Public Const DATA_FootCandle As Integer = (DATA_CLR_BASE Or &H102)
    Public Const DATA_CCT As Integer = (DATA_CLR_BASE Or &H103)
    Public Const DATA_LUX_S As Integer = (DATA_CLR_BASE Or &H104)
    Public Const DATA_LUX_SP As Integer = (DATA_CLR_BASE Or &H105)
    Public Const DATA_LUX_P As Integer = (DATA_CLR_BASE Or &H106)
    
    Public Const DATA_Purity As Integer = (DATA_CLR_BASE Or &H201)
    Public Const DATA_LumbdaP As Integer = (DATA_CLR_BASE Or &H202)
    Public Const DATA_LumbdaD As Integer = (DATA_CLR_BASE Or &H203)
    Public Const DATA_LambdaPV As Integer = (DATA_CLR_BASE Or &H204)
    
    Public Const DATA_PPF As Integer = (DATA_CLR_BASE Or &H301)
    Public Const DATA_PPFR As Integer = (DATA_CLR_BASE Or &H302)
    Public Const DATA_PPFG As Integer = (DATA_CLR_BASE Or &H303)
    Public Const DATA_PPFB As Integer = (DATA_CLR_BASE Or &H304)
    
    Public Const DATA_ExpTime As Integer = (DATA_CLR_BASE Or &H401)
    
    Public Const DATA_CRI_RA As Integer = (DATA_CRI_BASE Or &H1)
    Public Const DATA_CRI_R1 As Integer = (DATA_CRI_BASE Or &H2)
    Public Const DATA_CRI_R2 As Integer = (DATA_CRI_BASE Or &H3)
    Public Const DATA_CRI_R3 As Integer = (DATA_CRI_BASE Or &H4)
    Public Const DATA_CRI_R4 As Integer = (DATA_CRI_BASE Or &H5)
    Public Const DATA_CRI_R5 As Integer = (DATA_CRI_BASE Or &H6)
    Public Const DATA_CRI_R6 As Integer = (DATA_CRI_BASE Or &H7)
    Public Const DATA_CRI_R7 As Integer = (DATA_CRI_BASE Or &H8)
    Public Const DATA_CRI_R8 As Integer = (DATA_CRI_BASE Or &H9)
    Public Const DATA_CRI_R9 As Integer = (DATA_CRI_BASE Or &HA)
    Public Const DATA_CRI_R10 As Integer = (DATA_CRI_BASE Or &HB)
    Public Const DATA_CRI_R11 As Integer = (DATA_CRI_BASE Or &HC)
    Public Const DATA_CRI_R12 As Integer = (DATA_CRI_BASE Or &HD)
    Public Const DATA_CRI_R13 As Integer = (DATA_CRI_BASE Or &HE)
    Public Const DATA_CRI_R14 As Integer = (DATA_CRI_BASE Or &HF)
    Public Const DATA_CRI_R15 As Integer = (DATA_CRI_BASE Or &H10)
    
    Public Const DATA_GAI As Integer = (DATA_GAI_BASE Or &H0)
    Public Const DATA_GAI_up As Integer = (DATA_GAI_BASE Or &H1)
    Public Const DATA_GAI_vp As Integer = (DATA_GAI_BASE Or &H2)
    Public Const DATA_GAI_TCS1_up As Integer = (DATA_GAI_BASE Or &H3)
    Public Const DATA_GAI_TCS1_vp As Integer = (DATA_GAI_BASE Or &H4)
    Public Const DATA_GAI_TCS2_up As Integer = (DATA_GAI_BASE Or &H5)
    Public Const DATA_GAI_TCS2_vp As Integer = (DATA_GAI_BASE Or &H6)
    Public Const DATA_GAI_TCS3_up As Integer = (DATA_GAI_BASE Or &H7)
    Public Const DATA_GAI_TCS3_vp As Integer = (DATA_GAI_BASE Or &H8)
    Public Const DATA_GAI_TCS4_up As Integer = (DATA_GAI_BASE Or &H9)
    Public Const DATA_GAI_TCS4_vp As Integer = (DATA_GAI_BASE Or &HA)
    Public Const DATA_GAI_TCS5_up As Integer = (DATA_GAI_BASE Or &HB)
    Public Const DATA_GAI_TCS5_vp As Integer = (DATA_GAI_BASE Or &HC)
    Public Const DATA_GAI_TCS6_up As Integer = (DATA_GAI_BASE Or &HD)
    Public Const DATA_GAI_TCS6_vp As Integer = (DATA_GAI_BASE Or &HE)
    Public Const DATA_GAI_TCS7_up As Integer = (DATA_GAI_BASE Or &HF)
    Public Const DATA_GAI_TCS7_vp As Integer = (DATA_GAI_BASE Or &H10)
    Public Const DATA_GAI_TCS8_up As Integer = (DATA_GAI_BASE Or &H11)
    Public Const DATA_GAI_TCS8_vp As Integer = (DATA_GAI_BASE Or &H12)
    
    Public Const DATA_CQS As Integer = (DATA_CQS_BASE Or &H0)
    Public Const DATA_CQS_Q1 As Integer = (DATA_GAI_BASE Or &H1)
    Public Const DATA_CQS_Q2 As Integer = (DATA_GAI_BASE Or &H2)
    Public Const DATA_CQS_Q3 As Integer = (DATA_GAI_BASE Or &H3)
    Public Const DATA_CQS_Q4 As Integer = (DATA_GAI_BASE Or &H4)
    Public Const DATA_CQS_Q5 As Integer = (DATA_GAI_BASE Or &H5)
    Public Const DATA_CQS_Q6 As Integer = (DATA_GAI_BASE Or &H6)
    Public Const DATA_CQS_Q7 As Integer = (DATA_GAI_BASE Or &H7)
    Public Const DATA_CQS_Q8 As Integer = (DATA_GAI_BASE Or &H8)
    Public Const DATA_CQS_Q9 As Integer = (DATA_GAI_BASE Or &H9)
    Public Const DATA_CQS_Q10 As Integer = (DATA_GAI_BASE Or &HA)
    Public Const DATA_CQS_Q11 As Integer = (DATA_GAI_BASE Or &HB)
    Public Const DATA_CQS_Q12 As Integer = (DATA_GAI_BASE Or &HC)
    Public Const DATA_CQS_Q13 As Integer = (DATA_GAI_BASE Or &HD)
    Public Const DATA_CQS_Q14 As Integer = (DATA_GAI_BASE Or &HE)
    Public Const DATA_CQS_Q15 As Integer = (DATA_GAI_BASE Or &HF)
    
    Public Const DATA_TLCI As Integer = (DATA_TLCI_BASE Or &H0)
    
    Public Const DATA_TM30_RF As Integer = (DATA_TM30_BASE Or &H0)
    Public Const DATA_TM30_RG As Integer = (DATA_TM30_BASE Or &H1)
    
    Public Const INFO_MODELNAME As Integer = &H1001
    Public Const INFO_HWVER As Integer = &H1002
    Public Const INFO_FWVER As Integer = &H1003
    Public Const INFO_WLSTR As Integer = &H1004
    Public Const INFO_WLEND As Integer = &H1005
    
    ' Flicker value
    Public Const FLK_RMS_VALUE As Integer = &H1
    Public Const FLK_RMS_DB As Integer = &H2
    Public Const FLK_JEITA_VALUE As Integer = &H3
    Public Const FLK_JEITA_DB As Integer = &H4
    Public Const FLK_VESA_VALUE As Integer = &H5
    Public Const FLK_VESA_DB As Integer = &H6
    Public Const FLK_MAX_VALUE As Integer = &H7
    Public Const FLK_MIN_VALUE As Integer = &H8
    Public Const FLK_AVG_VALUE As Integer = &H9
    Public Const FLK_FMA_VALUE As Integer = &HA
    Public Const FLK_IES_INDEX_VALUE As Integer = &HB
    Public Const FLK_IES_PERCENT_VALUE As Integer = &HC
    Public Const FLK_SVM_VALUE As Integer = &HD
    Attached Files Attached Files

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2016
    Posts
    51

    Re: VB6 EXE does not work, but runs from VB6 IDE

    in Net module:

    Code:
    Imports System.Runtime.InteropServices
    Imports System.Text
    
    Public Class MK550T
        Const dllPath As String = "mkusb.dll"
    
        <DllImport(dllPath, EntryPoint:="mk_version", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_version() As UInteger
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Init", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)>
        Public Shared Function mk_Init(ByVal isMonitor As Integer, ByVal msec As Integer) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Close", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Sub mk_Close()
        End Sub
    
    
        <DllImport(dllPath, EntryPoint:="mk_IsUpdate", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_IsUpdate() As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_SpDevScan", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_SpDevScan() As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_FindFirst", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_FindFirst(ByVal name As StringBuilder) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_FindNext", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_FindNext(ByVal name As StringBuilder) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_FindClose", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_FindClose() As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_GetDeviceCnt", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_GetDeviceCnt() As Integer
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_GetOptSnByName", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_GetOptSnByName(ByVal name As StringBuilder, ByVal sn As StringBuilder) As Integer
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_OpenSpDev", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_OpenSpDev(ByVal name As StringBuilder) As Integer
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_OpenSpDev_OptSn", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_OpenSpDev_OptSn(ByVal sn As StringBuilder) As Integer
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_CloseSpDev", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_CloseSpDev(ByVal i As Integer) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Msr_AutoDarkCtrl", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Msr_AutoDarkCtrl(ByVal i As Integer, ByVal ctl As UInteger) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Msr_SetMaxExpTime", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Msr_SetMaxExpTime(ByVal i As Integer, ByVal maxtime As UInteger) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Msr_SetExpMode", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Msr_SetExpMode(ByVal i As Integer, ByVal mode As UInteger) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_Msr_Capture", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Msr_Capture(ByVal i As Integer, ByVal isAuto As UShort, ByVal ExpTime As UShort) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Msr_Dark", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Msr_Dark(ByVal i As Integer) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_GetData", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_GetData(ByVal i As Integer, ByVal type As Integer, ByRef data As Single) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_GetSpectrum", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_GetSpectrum(ByVal i As Integer, ByVal str As Integer, ByVal stp As Integer, ByVal data() As Single) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_GetMicroMole", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_GetMicroMole(ByVal i As Integer, ByVal str As Integer, ByVal stp As Integer, ByVal data() As Single) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_GetOptSn", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_GetOptSn(ByVal i As Integer, ByVal sn As StringBuilder) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_GetLightStrnegth", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_GetLightStrnegth(ByVal i As Integer) As Integer
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Peri_GetTemp", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Peri_GetTemp(ByVal i As Integer, ByRef data As Single) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Peri_SetLCD", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Peri_SetLCD(ByVal i As Integer, ByVal data As UShort) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Peri_KeyEnable", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Peri_KeyEnable(ByVal i As Integer) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Peri_KeyDisable", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Peri_KeyDisable(ByVal i As Integer) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Peri_KeyClear", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Peri_KeyClear(ByVal i As Integer) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Peri_KeyGet", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Peri_KeyGet(ByVal i As Integer) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_Info_Get", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Info_Get(ByVal i As Integer, ByVal id As Integer, ByVal str_info As StringBuilder) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_flk_Dark", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_flk_Dark(ByVal i As Integer) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_flk_SetPara", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_flk_SetPara(ByVal i As Integer, ByVal sample_num As UInteger, ByVal sampel_freq As UInteger, ByVal fir_num As UInteger, ByVal fir_cutfreq As UInteger) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_flk_Capture", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_flk_Capture(ByVal i As Integer, ByVal isAutoGain As UShort, ByVal gain As UShort, ByVal enable_fir As UShort) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_flk_GetData", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_flk_GetData(ByVal i As Integer, ByVal type As Integer, ByRef data As Single) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_flk_GetTimeDomainWaveform", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_flk_GetTimeDomainWaveform(ByVal i As Integer, ByVal size As Integer, ByVal data() As Single) As Boolean
        End Function
    
    
        <DllImport(dllPath, EntryPoint:="mk_flk_GetFreqDomainWaveform", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_flk_GetFreqDomainWaveform(ByVal i As Integer, ByVal size As Integer, ByVal freq() As Single, ByVal data() As Single) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_senr_Msr_Capture", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_senr_Msr_Capture(ByVal i As Integer, ByVal isAuto As UShort, ByVal ExpTime As UInteger) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_senr_Msr_Dark", SetLastError:=TRUE, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_senr_Msr_Dark(ByVal i As Integer) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_Msr_SetCorrMatrixCH", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Msr_SetCorrMatrixCH(ByVal i As Integer, ByVal ch As Integer) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_Msr_GetCorrMatrixPara", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Msr_GetCorrMatrixPara(ByVal i As Integer, ByVal ch As Integer, ByVal name As StringBuilder, ByVal data() As Double) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_Msr_SetCorrMatrixPara", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Msr_SetCorrMatrixPara(ByVal i As Integer, ByVal ch As Integer, ByVal name As StringBuilder, ByVal data() As Double) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_Msr_GenerateCorrMatrix", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Msr_GenerateCorrMatrix(ByVal Ref() As Double, ByVal mes() As Double, ByVal len As Integer, ByVal corr() As Double, ByVal colorspace As Integer) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_sflk_Dark", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_sflk_Dark(ByVal i As Integer, ByVal uexptime As UInteger, ByVal sampletime As UInteger) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_sflk_SetPara", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_sflk_SetPara(ByVal i As Integer, ByVal sample_num As UInteger, ByVal sample_freq As UInteger, ByVal fir_num As UInteger, ByVal fir_cutfreq As UInteger) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_sflk_Capture", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_sflk_Capture(ByVal i As Integer, ByVal uexptime As UInteger, ByVal enable_fir As UShort) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_sflk_CaptureRaw", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_sflk_CaptureRaw(ByVal i As Integer, ByVal uexptime As UInteger, ByRef ptr As IntPtr) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_sflk_GetData", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_sflk_GetData(ByVal i As Integer, ByVal type As Integer, ByRef data As Single) As Boolean
        End Function
    
        <DllImport(dllPath, EntryPoint:="mk_senr_GetPeakSpRaw", SetLastError:=TRUE, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_senr_GetPeakSpRaw(ByVal i As integer, ByVal exptime As integer,ByRef data As UIntPtr) As Boolean
        End Function
    
        Public Const DATA_CLR_BASE As Integer = &H0
        Public Const DATA_CRI_BASE As Integer = &H1000
        Public Const DATA_GAI_BASE As Integer = &H2000
        Public Const DATA_CQS_BASE As Integer = &H3000
        Public Const DATA_TM30_BASE As Integer = &H5000
        Public Const DATA_TLCI_BASE As Integer = &H4000
        Public Const DATA_OTH_BASE As Integer = &H8000
    
        Public Const DATA_CIE1931_x As Integer = (DATA_CLR_BASE Or &H1)
        Public Const DATA_CIE1931_y As Integer = (DATA_CLR_BASE Or &H2)
        Public Const DATA_CIE_X As Integer = (DATA_CLR_BASE Or &H3)
        Public Const DATA_CIE_Y As Integer = (DATA_CLR_BASE Or &H4)
        Public Const DATA_CIE_Z As Integer = (DATA_CLR_BASE Or &H5)
        Public Const DATA_CIE1964_x10 As Integer = (DATA_CLR_BASE Or &H6)
        Public Const DATA_CIE1964_y10 As Integer = (DATA_CLR_BASE Or &H7)
        Public Const DATA_CIE_X10 As Integer = (DATA_CLR_BASE Or &H8)
        Public Const DATA_CIE_Y10 As Integer = (DATA_CLR_BASE Or &H9)
        Public Const DATA_CIE_Z10 As Integer = (DATA_CLR_BASE Or &HA)
    
        Public Const DATA_CIE1976_up As Integer = (DATA_CLR_BASE Or &H11)
        Public Const DATA_CIE1976_vp As Integer = (DATA_CLR_BASE Or &H12)
        Public Const DATA_CIE1976_up10 As Integer = (DATA_CLR_BASE Or &H13)
        Public Const DATA_CIE1976_vp10 As Integer = (DATA_CLR_BASE Or &H14)
        Public Const DATA_CIE1960_du As Integer = (DATA_CLR_BASE Or &H21)
        Public Const DATA_CIE1960_dv As Integer = (DATA_CLR_BASE Or &H22)
        Public Const DATA_LUX As Integer = (DATA_CLR_BASE Or &H101)
        Public Const DATA_L As Integer = (DATA_CLR_BASE Or &H101)
        Public Const DATA_FootCandle As Integer = (DATA_CLR_BASE Or &H102)
        Public Const DATA_CCT As Integer = (DATA_CLR_BASE Or &H103)
        Public Const DATA_LUX_S As Integer = (DATA_CLR_BASE Or &H104)
        Public Const DATA_LUX_SP As Integer = (DATA_CLR_BASE Or &H105)
        Public Const DATA_LUX_P As Integer = (DATA_CLR_BASE Or &H106)
    
        Public Const DATA_Purity As Integer = (DATA_CLR_BASE Or &H201)
        Public Const DATA_LumbdaP As Integer = (DATA_CLR_BASE Or &H202)
        Public Const DATA_LumbdaD As Integer = (DATA_CLR_BASE Or &H203)
        Public Const DATA_LambdaPV As Integer = (DATA_CLR_BASE Or &H204)
    
        Public Const DATA_PPF As Integer = (DATA_CLR_BASE Or &H301)
        Public Const DATA_PPFR As Integer = (DATA_CLR_BASE Or &H302)
        Public Const DATA_PPFG As Integer = (DATA_CLR_BASE Or &H303)
        Public Const DATA_PPFB As Integer = (DATA_CLR_BASE Or &H304)
    
        Public Const DATA_ExpTime As Integer = (DATA_CLR_BASE Or &H401)
    
        Public Const DATA_CRI_RA As Integer = (DATA_CRI_BASE Or &H1)
        Public Const DATA_CRI_R1 As Integer = (DATA_CRI_BASE Or &H2)
        Public Const DATA_CRI_R2 As Integer = (DATA_CRI_BASE Or &H3)
        Public Const DATA_CRI_R3 As Integer = (DATA_CRI_BASE Or &H4)
        Public Const DATA_CRI_R4 As Integer = (DATA_CRI_BASE Or &H5)
        Public Const DATA_CRI_R5 As Integer = (DATA_CRI_BASE Or &H6)
        Public Const DATA_CRI_R6 As Integer = (DATA_CRI_BASE Or &H7)
        Public Const DATA_CRI_R7 As Integer = (DATA_CRI_BASE Or &H8)
        Public Const DATA_CRI_R8 As Integer = (DATA_CRI_BASE Or &H9)
        Public Const DATA_CRI_R9 As Integer = (DATA_CRI_BASE Or &HA)
        Public Const DATA_CRI_R10 As Integer = (DATA_CRI_BASE Or &HB)
        Public Const DATA_CRI_R11 As Integer = (DATA_CRI_BASE Or &HC)
        Public Const DATA_CRI_R12 As Integer = (DATA_CRI_BASE Or &HD)
        Public Const DATA_CRI_R13 As Integer = (DATA_CRI_BASE Or &HE)
        Public Const DATA_CRI_R14 As Integer = (DATA_CRI_BASE Or &HF)
        Public Const DATA_CRI_R15 As Integer = (DATA_CRI_BASE Or &H10)
    
        Public Const DATA_GAI As Integer = (DATA_GAI_BASE Or &H0)
        Public Const DATA_GAI_up As Integer = (DATA_GAI_BASE Or &H1)
        Public Const DATA_GAI_vp As Integer = (DATA_GAI_BASE Or &H2)
        Public Const DATA_GAI_TCS1_up As Integer = (DATA_GAI_BASE Or &H3)
        Public Const DATA_GAI_TCS1_vp As Integer = (DATA_GAI_BASE Or &H4)
        Public Const DATA_GAI_TCS2_up As Integer = (DATA_GAI_BASE Or &H5)
        Public Const DATA_GAI_TCS2_vp As Integer = (DATA_GAI_BASE Or &H6)
        Public Const DATA_GAI_TCS3_up As Integer = (DATA_GAI_BASE Or &H7)
        Public Const DATA_GAI_TCS3_vp As Integer = (DATA_GAI_BASE Or &H8)
        Public Const DATA_GAI_TCS4_up As Integer = (DATA_GAI_BASE Or &H9)
        Public Const DATA_GAI_TCS4_vp As Integer = (DATA_GAI_BASE Or &HA)
        Public Const DATA_GAI_TCS5_up As Integer = (DATA_GAI_BASE Or &HB)
        Public Const DATA_GAI_TCS5_vp As Integer = (DATA_GAI_BASE Or &HC)
        Public Const DATA_GAI_TCS6_up As Integer = (DATA_GAI_BASE Or &HD)
        Public Const DATA_GAI_TCS6_vp As Integer = (DATA_GAI_BASE Or &HE)
        Public Const DATA_GAI_TCS7_up As Integer = (DATA_GAI_BASE Or &HF)
        Public Const DATA_GAI_TCS7_vp As Integer = (DATA_GAI_BASE Or &H10)
        Public Const DATA_GAI_TCS8_up As Integer = (DATA_GAI_BASE Or &H11)
        Public Const DATA_GAI_TCS8_vp As Integer = (DATA_GAI_BASE Or &H12)
    
        Public Const DATA_CQS As Integer = (DATA_CQS_BASE Or &H0)
        Public Const DATA_CQS_Q1 As Integer = (DATA_GAI_BASE Or &H1)
        Public Const DATA_CQS_Q2 As Integer = (DATA_GAI_BASE Or &H2)
        Public Const DATA_CQS_Q3 As Integer = (DATA_GAI_BASE Or &H3)
        Public Const DATA_CQS_Q4 As Integer = (DATA_GAI_BASE Or &H4)
        Public Const DATA_CQS_Q5 As Integer = (DATA_GAI_BASE Or &H5)
        Public Const DATA_CQS_Q6 As Integer = (DATA_GAI_BASE Or &H6)
        Public Const DATA_CQS_Q7 As Integer = (DATA_GAI_BASE Or &H7)
        Public Const DATA_CQS_Q8 As Integer = (DATA_GAI_BASE Or &H8)
        Public Const DATA_CQS_Q9 As Integer = (DATA_GAI_BASE Or &H9)
        Public Const DATA_CQS_Q10 As Integer = (DATA_GAI_BASE Or &HA)
        Public Const DATA_CQS_Q11 As Integer = (DATA_GAI_BASE Or &HB)
        Public Const DATA_CQS_Q12 As Integer = (DATA_GAI_BASE Or &HC)
        Public Const DATA_CQS_Q13 As Integer = (DATA_GAI_BASE Or &HD)
        Public Const DATA_CQS_Q14 As Integer = (DATA_GAI_BASE Or &HE)
        Public Const DATA_CQS_Q15 As Integer = (DATA_GAI_BASE Or &HF)
    
        Public Const DATA_TLCI As Integer = (DATA_TLCI_BASE Or &H0)
    
        Public Const DATA_TM30_RF As Integer = (DATA_TM30_BASE Or &H0)
        Public Const DATA_TM30_RG As Integer = (DATA_TM30_BASE Or &H1)
    
        Public Const INFO_MODELNAME As Integer = &H1001
        Public Const INFO_HWVER As Integer = &H1002
        Public Const INFO_FWVER As Integer = &H1003
        Public Const INFO_WLSTR As Integer = &H1004
        Public Const INFO_WLEND As Integer = &H1005
    
        ' Flicker value
        Public Const FLK_RMS_VALUE As Integer = &H1
        Public Const FLK_RMS_DB As Integer = &H2
        Public Const FLK_JEITA_VALUE As Integer = &H3
        Public Const FLK_JEITA_DB As Integer = &H4
        Public Const FLK_VESA_VALUE As Integer = &H5
        Public Const FLK_VESA_DB As Integer = &H6
        Public Const FLK_MAX_VALUE As Integer = &H7
        Public Const FLK_MIN_VALUE As Integer = &H8
        Public Const FLK_AVG_VALUE As Integer = &H9
        Public Const FLK_FMA_VALUE As Integer = &HA
        Public Const FLK_IES_INDEX_VALUE As Integer = &HB
        Public Const FLK_IES_PERCENT_VALUE As Integer = &HC
        Public Const FLK_SVM_VALUE As Integer = &HD
    
    End Class

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2016
    Posts
    51

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by Arnoutdv View Post
    Maybe it needs some time to complete?

    Can you explain what this is about?
    mk_Msr... etc etc
    mk_Msr... is function in module, from dll

    I use Ctrl+F5 can run, but create exe can't run

    (my english not good,sorry)

  6. #6
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,375

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by kevin651212 View Post
    mk_Msr... is function in module, from dll

    I use Ctrl+F5 can run, but create exe can't run

    (my english not good,sorry)
    The Run menu has an option to run with full compile (which I use 100% of the time)
    No doubt you will get the same error as you get when attempting to make exe.
    But, there is a chance that you may get more information about the problem

  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,970

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Maybe the VB6 declarations are not oke?
    I see some Integer references in the VB.Net declarations, but I believe an Integer in VB.Net is a Long in VB6

    https://docs.microsoft.com/en-us/dot...eger-data-type

  8. #8
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,719

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Can you provide more information than "can't run"? Does the application just not run, does it run and crash, does it work but not do what you expect, is there a message box reporting an error, does it blue screen your OS, does it cause your PC to dance? Provide a little more detail on this if you can.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  9. #9

    Thread Starter
    Member
    Join Date
    Sep 2016
    Posts
    51

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by Bobbles View Post
    The Run menu has an option to run with full compile (which I use 100% of the time)
    No doubt you will get the same error as you get when attempting to make exe.
    But, there is a chance that you may get more information about the problem
    full compile is ok, but run exe crash and no message

  10. #10

    Thread Starter
    Member
    Join Date
    Sep 2016
    Posts
    51

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by Niya View Post
    Can you provide more information than "can't run"? Does the application just not run, does it run and crash, does it work but not do what you expect, is there a message box reporting an error, does it blue screen your OS, does it cause your PC to dance? Provide a little more detail on this if you can.
    run exe only crash and no message , I guess it is a UInteger problem?

    I will try again, if it fails, I will try to use VB.Net,tks

  11. #11

    Thread Starter
    Member
    Join Date
    Sep 2016
    Posts
    51

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Ok,I will try it,tks

  12. #12

    Thread Starter
    Member
    Join Date
    Sep 2016
    Posts
    51

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by Arnoutdv View Post
    Maybe the VB6 declarations are not oke?
    I see some Integer references in the VB.Net declarations, but I believe an Integer in VB.Net is a Long in VB6

    https://docs.microsoft.com/en-us/dot...eger-data-type
    Ok,I will try it,tks

  13. #13
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,719

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by kevin651212 View Post
    run exe only crash and no message , I guess it is a UInteger problem?
    If I remember correctly, VB6 applications crash this way when it's messing around with outside of its sandbox such as with your API calls and it's done incorrectly. I'd look into what Arnoutdv suggested about the data types used in the API declarations. If, as he suggested, you are indeed using Integers where you're supposed to use Longs or vice versa, it would lead to stack corruption which can typically cause VB6 to behave the way you described.

    If you're unsure whether to use an Integer or a Long then look at the size of the data types the DLL functions require. A 4 byte or 32 bit integer data type is typically of type int in C/C++, Integer in VB.Net but it's a Long in VB6. A 16 bit or 2 byte integer data type is called a short in C/C++/C#/VB.Net but it's called Integer in VB6.

    I don't know if you wrote those API declarations yourself but if they were prototyped in C or C++, and you used those prototypes to come up with their VB6 equivalents yourself, then you need to be aware of nuances between how different environments treat data types with the same name. An Integer data type in one language may not be the same as an Integer in another.
    Last edited by Niya; Oct 26th, 2020 at 12:36 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  14. #14

    Thread Starter
    Member
    Join Date
    Sep 2016
    Posts
    51

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by Niya View Post
    If I remember correctly, VB6 applications crash this way when it's messing around with outside of its sandbox such as with your API calls and it's done incorrectly. I'd look into what Arnoutdv suggested about the data types used in the API declarations. If, as he suggested, you are indeed using Integers where you're supposed to use Longs or vice versa, it would lead to stack corruption which can typically cause VB6 to behave the way you described.

    If you're unsure whether to use an Integer or a Long then look at the size of the data types the DLL functions require. A 4 byte or 32 bit integer data type is typically of type int in C/C++, Integer in VB.Net but it's a Long in VB6. A 16 bit or 2 byte integer data type is called a short in C/C++/C#/VB.Net but it's called Integer in VB6.

    I don't know if you wrote those API declarations yourself but if they were prototyped in C or C++, and you used those prototypes to come up with their VB6 equivalents yourself, then you need to be aware of nuances between how different environments treat data types with the same name. An Integer data type in one language may not be the same as an Integer in another.
    The dll declaration comes from the manufacturer's sample. The dll originally only supports C#, Net, and does not support VB6. Please modify the dll and provide the VB6 sample. I will try to modify the data type, thank you

  15. #15
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    463

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by kevin651212 View Post
    The dll declaration comes from the manufacturer's sample. The dll originally only supports C#, Net, and does not support VB6. Please modify the dll and provide the VB6 sample. I will try to modify the data type, thank you
    something maybe is cdecl,like sqlite.dll
    so,you need call dll by cdecl method

  16. #16
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,719

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by kevin651212 View Post
    The dll declaration comes from the manufacturer's sample. The dll originally only supports C#, Net, and does not support VB6. Please modify the dll and provide the VB6 sample. I will try to modify the data type, thank you
    I don't have VB6 currently installed as I use .Net now and haven't used VB6 seriously in years. I also do not have these dlls so I cannot test it myself. Besides all that, I really don't have the the time to do those modifications for you. But I can tell you how to fix your problem based on the information you provided.

    You said that the original declarations are for .Net and I noticed that you posted these .Net declarations in an earlier post. You need to fix some of the data types. Change all Integer and UInteger to Long. Change all Short and UShort to Integer. This is the most significant thing I noticed. This may in fact be the source of all your problems and just these changes would may be all you need to get it to work. I see some other things like arrays, pointers and by reference parameters being passed which may need to be looked at. There are some potential problems there too. Pointers, arrays etc have to be treated with a lot more care. If changing the Integers don't make them all work then we would take a look at the more tricky functions.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  17. #17
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,719

    Re: VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by kevin651212 View Post
    I will try to use VB.Net,tks
    Also, I'm curious about this. If you're willing to entertain this as a solution then why even bother using VB6 at all?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  18. #18
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,538

    Re: [RESOLVED] VB6 EXE does not work, but runs from VB6 IDE

    Take a closer look at the alias in the declaration for example:
    Code:
    Declare Function mk_Msr_AutoDarkCtrl Lib "mkusb.dll" Alias "_mk_Msr_AutoDarkCtrl@8" _
          (ByVal i As Integer, ByVal ctl As Long) As Boolean
    The highlighted @8 in that alias means something, correct? Doesn't it mean that the parameters total 8 bytes? If so, then the parameters are defined incorrectly because they total 6 bytes (2 for integer, 4 for long) not 8 bytes. To get 8 bytes from those 2 parameters, both can be Long or one is long and the other is ByRef (4 byte pointer) or both are ByRef.

    Edited: If the above is true, every API declaration needs to be re-examined since they include the @xx suffix in the alias.

    Edited again & FYI. Storage for .Net variable types
    https://www.tutorialspoint.com/vb.ne...data_types.htm
    Last edited by LaVolpe; Oct 28th, 2020 at 11:34 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  19. #19
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,719

    Re: [RESOLVED] VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by LaVolpe View Post
    Take a closer look at the alias in the declaration for example:
    Code:
    Declare Function mk_Msr_AutoDarkCtrl Lib "mkusb.dll" Alias "_mk_Msr_AutoDarkCtrl@8" _
          (ByVal i As Integer, ByVal ctl As Long) As Boolean
    The highlighted @8 in that alias means something, correct? Doesn't it mean that the parameters total 8 bytes? If so, then the parameters are defined incorrectly because they total 6 bytes (2 for integer, 4 for long) not 8 bytes. To get 8 bytes from those 2 parameters, both can be Long or one is long and the other is ByRef (4 byte pointer) or both are ByRef.

    Edited: If the above is true, every API declaration needs to be re-examined since they include the @xx suffix in the alias.
    Most of them appear to be correct. However, that one is both correct and wrong at the same time. If we go strictly by what is written there then it should be @6. However when I look at the .Net prototype he posted, I see this:-
    vbnet Code:
    1. '
    2. <DllImport(dllPath, EntryPoint:="mk_Msr_AutoDarkCtrl", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
    3.  Public Shared Function mk_Msr_AutoDarkCtrl(ByVal i As Integer, ByVal ctl As UInteger) As Boolean
    4.  End Function

    So it's correct in the sense that the actual function being called does expect 8 bytes to be allocated on the stack for it's parameters. The problem in this case is not actually the alias but the prototype itself. It should be this instead:-
    vb6 Code:
    1. Declare Function mk_Msr_AutoDarkCtrl Lib "mkusb.dll" Alias "_mk_Msr_AutoDarkCtrl@8" (ByVal i As Long, ByVal ctl As Long) As Boolean
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  20. #20
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,538

    Re: [RESOLVED] VB6 EXE does not work, but runs from VB6 IDE

    @Niya. Agree except I think @8 is correct vs. @6
    Those DLLImport samples were extracted from a .Net module per the OP. Well a .Net Integer/UInteger = VB Long where a .Net Short/UShort = VB Integer. It sounds like it is a matter of cleaning up the parameters and/or function return value and trying again. One can use the parameter size in the alias to help confirm the changes at least tally correctly.

    ^^ above is incorrect I believe. The @8 is stack size for all parameters. That value seems to always be a multiple of 4. For example, look at mk_Peri_SetLCD. It has the @8 suffix but its .Net param vartypes in the DLLImport section are Integer (4 bytes) & UShort (2 bytes). That tallies to 6 bytes not 8. But that API is a good example of how messed up the VB API declarations may be. These parameters when compared to each declaration are not even close:
    Code:
        <DllImport(dllPath, EntryPoint:="mk_Peri_SetLCD", SetLastError:=True, CallingConvention:=CallingConvention.StdCall)> _
        Public Shared Function mk_Peri_SetLCD(ByVal i As Integer, ByVal data As UShort) As Boolean
        End Function
    
    Declare Function mk_Peri_SetLCD Lib "mkusb.dll" Alias "_mk_Peri_SetLCD@8" _
         (ByVal i As Integer, ByVal data As Long) As Boolean
    edited: In the Win32 stack, parameters occupy DWord, 4-byte, blocks. So if a VB integer is passed, it occupies 4 bytes on the stack, regardless that 2 bytes were passed. The internal code will only access 2 bytes if indeed a 2 byte value is expected. Well, the API causing the crash appears to be passed an Integer "ID" parameter. ID is usually a parameter name reserved for really important values. So, 2 bytes were passed to API for the ID and the other 2 bytes on the stack remain undefined (not necessarily zeroed out). But the API is really expecting 4 bytes so it grabs all 4 bytes from the stack parameter slot: the 2 that were passed + the 2 undefined bytes to form an ID. In that scenario, one can make an assumption that a bad ID can cause a crash.
    Last edited by LaVolpe; Oct 28th, 2020 at 01:05 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  21. #21
    Hyperactive Member
    Join Date
    Jan 2020
    Posts
    463

    Re: [RESOLVED] VB6 EXE does not work, but runs from VB6 IDE

    you can use vb.net make a com dll,so call by vb6

  22. #22
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,719

    Re: [RESOLVED] VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by LaVolpe View Post
    ^^ above is incorrect I believe. The @8 is stack size for all parameters. That value seems to always be a multiple of 4. For example, look at mk_Peri_SetLCD. It has the @8 suffix but its .Net param vartypes in the DLLImport section are Integer (4 bytes) & UShort (2 bytes). That tallies to 6 bytes not 8.
    I'd be very careful about making this assumption. As you can see here, Intel processors are fully capable of pushing 16 byte values onto the stack. I'm referring specifically to these versions of the PUSH instruction:-
    asm Code:
    1. '
    2. PUSH r/m16
    3. PUSH r16
    4. PUSH imm16

    Now there is a very good reason to want to ONLY push multiple of 32 bit values. Memory access is more efficient when dealing with addresses that are aligned to 4 byte boundaries and pushing 16 bit values can have a performance impact because it can screw up alignment of the stack. However, in my opinion, it's not safe to assume that a compiler will do that. This is also why programmers are strongly encouraged to use 32 bit Integer data types whenever possible.

    You might be correct about what you're saying but in situations like this it's better to never assume that compilers won't generate instructions to push 16 bit values onto the stack for function calls.

    When I have the time, I'll look into this in more detail.
    Last edited by Niya; Nov 2nd, 2020 at 05:44 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  23. #23
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    2,419

    Re: [RESOLVED] VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by Niya View Post
    However, in my opinion, it's not safe to assume that a compiler will do that.

    . . .

    You might be correct about what you're saying but in situations like this it's better to never assume that compilers won't generate instructions to push 16 bit values onto the stack for function calls.
    Stack alignment is stdcall (and cdecl) ABI specific, not compiler specific, and on x86 it's mandatory for parameters of *any* datatype on the stack to be 4-bytes aligned both for stdcall and cdecl. On x64 this alignment increases to 16 bytes.

    For instance VB's Boolean (so called VT_BOOL) is 2-bytes longs but gets aligned the way Integer (so called VT_I2) to 4-bytes on the stack padded with zeroes.

    In C/C++ contrary to VB6 a function might accept structs "ByVal" i.e. on the stack and its argument value has to be 4-bytes aligned as well.

    cheers,
    </wqw>

  24. #24
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    5,719

    Re: [RESOLVED] VB6 EXE does not work, but runs from VB6 IDE

    Quote Originally Posted by wqweto View Post
    Stack alignment is stdcall (and cdecl) ABI specific, not compiler specific, and on x86 it's mandatory for parameters of *any* datatype on the stack to be 4-bytes aligned both for stdcall and cdecl. On x64 this alignment increases to 16 bytes.

    For instance VB's Boolean (so called VT_BOOL) is 2-bytes longs but gets aligned the way Integer (so called VT_I2) to 4-bytes on the stack padded with zeroes.

    In C/C++ contrary to VB6 a function might accept structs "ByVal" i.e. on the stack and its argument value has to be 4-bytes aligned as well.

    cheers,
    </wqw>
    Ah well. There we go.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width