Click here to Skip to main content
15,915,093 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Using USB port Pin
Dave Kreskowiak17-Jun-06 16:37
mveDave Kreskowiak17-Jun-06 16:37 
QuestionWin APIs different in debug/release (.NET?) Pin
rberman17-Jun-06 10:09
rberman17-Jun-06 10:09 
AnswerRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak17-Jun-06 16:39
mveDave Kreskowiak17-Jun-06 16:39 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman18-Jun-06 4:57
rberman18-Jun-06 4:57 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak18-Jun-06 8:02
mveDave Kreskowiak18-Jun-06 8:02 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman18-Jun-06 10:30
rberman18-Jun-06 10:30 
GeneralRe: Win APIs different in debug/release (.NET?) [modified] Pin
Dave Kreskowiak19-Jun-06 1:25
mveDave Kreskowiak19-Jun-06 1:25 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman19-Jun-06 4:29
rberman19-Jun-06 4:29 
Believe me, it makes no sense to me either, other than as a compiler or linker bug. Here's the declares:

Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
(ByVal lpFilename As String, ByVal dwDesiredAccess As Int32, _
ByVal dwShareMode As Int32, ByVal lpSecurityAttributes As Int32, _
ByVal dwCreationDisposition As Int32, ByVal dwFlagsAndAttributes As Int32, _
ByVal hTemplateFile As Int32) As Int32


Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Int32, ByVal lpBuffer As String, ByVal nNumberOfBytesToWrite As Int32, _
ByRef lpNumberOfBytesWritten As Int32, ByRef lpOverlapped As Int32) As Int32

Private Const GENERIC_WRITE As Int32 = &H40000000


Here's the two calls:

Dim lMailslotHandle As Int32
Dim lResult As Int32
Dim lNumWritten As Int32

lMailslotHandle = CreateFile(sMailSlot, GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)

lResult = WriteFile(lMailslotHandle, sMsg2, Len(sMsg2), lNumWritten, 0)
Private Const FILE_SHARE_READ As Int32 = &H1

Note that for mailslots, one MUST use FILE_SHARE_READ in CreateFile.

The error in release mode is typically "invalid handle" on the Writefile. Here's a bit more. If I run the release version form the IDE (i.e. in debug mode, but not debug compile) it does not give the error, and works fine. Perhaps that really uses debug mode.

There's more weirdness. The DLL that contains this is supposed to be called via COM, and I have the appropriate COM registration for this. I have two test programs for the DLL -- one in .NET, one in VB6, more or less identical. However, when called from COM (i.e. a VB6 app), the debug version ALSO fails with invalid handle, but succeeds when called from .NET. To make it worse (better?) all I do to test is create an instance of the DLL object, as all this happens in the New() method -- so there isn't any problem in argument or result marshalling to account for this. In all cases (working or failure), logging shows the handle from CreateFile is still intact at the time WriteFile fails.




GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak19-Jun-06 5:08
mveDave Kreskowiak19-Jun-06 5:08 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman19-Jun-06 5:32
rberman19-Jun-06 5:32 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak19-Jun-06 12:44
mveDave Kreskowiak19-Jun-06 12:44 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman19-Jun-06 6:30
rberman19-Jun-06 6:30 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak19-Jun-06 12:42
mveDave Kreskowiak19-Jun-06 12:42 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman19-Jun-06 7:00
rberman19-Jun-06 7:00 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak19-Jun-06 12:47
mveDave Kreskowiak19-Jun-06 12:47 
QuestionSource code for zedgraph bar chart (for 5 Bars needed) [modified] Pin
eric123916-Jun-06 23:24
eric123916-Jun-06 23:24 
QuestionAddressOf CopyProgressRoutine Pin
maple_kisses16-Jun-06 23:13
maple_kisses16-Jun-06 23:13 
AnswerRe: AddressOf CopyProgressRoutine Pin
Dave Kreskowiak17-Jun-06 16:45
mveDave Kreskowiak17-Jun-06 16:45 
Questionplease hepl me Pin
avinashprabhu.t.p16-Jun-06 20:13
avinashprabhu.t.p16-Jun-06 20:13 
AnswerRe: please hepl me Pin
Dave Kreskowiak17-Jun-06 16:46
mveDave Kreskowiak17-Jun-06 16:46 
QuestionInternet disabling/enabling Pin
elms16-Jun-06 19:46
elms16-Jun-06 19:46 
AnswerRe: Internet disabling/enabling Pin
Dave Kreskowiak17-Jun-06 16:50
mveDave Kreskowiak17-Jun-06 16:50 
GeneralRe: Internet disabling/enabling Pin
elms28-Jun-06 9:34
elms28-Jun-06 9:34 
GeneralRe: Internet disabling/enabling Pin
Dave Kreskowiak29-Jun-06 1:23
mveDave Kreskowiak29-Jun-06 1:23 
QuestionDir() function Pin
No-e16-Jun-06 8:49
No-e16-Jun-06 8:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.