If MsgBox("Click Yes to apply DLL options over a Standard EXE Project," & vbCrLf & "otherwise click No to let VB handle the usual way.", vbYesNo) = vbNo Then
LINK ' Default
End If
End If
End Sub
Sub LINK(Optional CmdLine As String = vbNullString)
If CmdLine = vbNullString Then CmdLine = Command$
If CmdLine = vbNullString Then
Unload Me
Exit Sub
End If
Open App.Path & "\LinkerLog.txt" For Append As #1
Print #1, Now & ": ============================================"
Print #1, Now & ": Command Line Options: "; Command$
If CmdLine <> Command$ Then
Print #1, Now & ": Command Line Options: "; CmdLine ' Write only if there was a change
End If
Print #1, Now & ": ============================================"
Print #1, vbCrLf & vbCrLf
Close #1
ShellWait App.Path & "\" & LINK_FILE & " " & CmdLine ' i.e.: My SuperShell function
Unload Me
End Sub
Do i put this code in a *form* (i noticed CmdOK and CmdCancel functions in the code..) or a *module*?
Do i add any references to the project?
I keep getting an error with the 'shellwait' lines saing its not defined or something
Please may someone help me with this. It's just the linker part which im having problems with, awaiting your replies, many thanks in advance!!
Re: question for penagate,moeur or codeblock pls regarding dll
You need a reference to Microsoft Scripting Runtime to use the FileSystemObject and I'm guessing that ShellWait is a routine written by codeblock which shells to a process synchronously, ie waits for the process to finish before continuing. If I'm guessing correctly, this code should substitute for codeblock's ShellWait routine. Put this code in a module.
VB Code:
Option Explicit
'
' Windows API Declarations for executing (shell) a process synchronously
'
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Const STARTF_USESHOWWINDOW As Long = &H1
Private Const SW_HIDE As Long = &H0
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" _
(ByVal lpApplicationName As Long, ByVal lpCommandLine As String, _
ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Sub ShellWait(ByVal cmd As String, Optional Parameters As String = "", Optional ByVal HideWindow As Boolean = False)
'
' Shell to a process and wait for it to finish executing
Re: question for penagate,moeur or codeblock pls regarding dll
ok i changed the exe to a dll, and then i made a brand new exe testing the dll, but it just keeps saying 'can't find the MathLib.dll'
Please can help me, i am desperate to get this working, thanks alot for all your help so far, this is the dll project and the dlltest project, please if you have time look at it, thanks
Re: question for penagate,moeur or codeblock pls regarding dll
Pouncer,
I am working on it
I have to get my brain back to where it was when I last worked on this problem.
One thing I remember is that if the VB linker runs into an error, it won't give you an error message, it simply does not produce the output file.
To get the error messages, I have to run the command through the VC++ linker in a CMD window. The command being the command line after modification from the log file.
You have to do this at the point that the link wrapper is asking you whether you want to proceed or not other wise the obj files will not exist.
Also, when you compile your exe, you can give it the dll name.
Re: question for penagate,moeur or codeblock pls regarding dll
wow moeur thats brilliantt!!!! you got it working on your side now i know there is 100% hope!!!!
but on my side, im using your wrapper code and done exactly as you wrote, i clicked on 'Make MathLib.dll' and i clicked yes on the prompt: 'Make changes to link options'
but it does not produce no MathLib.dll in the direcotry of the project
Re: question for penagate,moeur or codeblock pls regarding dll
but it does not produce no MathLib.dll in the direcotry of the project
Did you declare your DllMain exactly as I posted it? Cut and paste that declaration so that you don't make a type. The case of DllMain is important. My wrapper expects DllMain not DLLMain as codebank's wrapper expects.
Re: question for penagate,moeur or codeblock pls regarding dll
i check the code over and over and it is exactly how you wrote, i use DllMain in your linker and your exact dll declaration (which i pasted as you said), i cant seem to find the problem at all (im on win xp too, i looked in system32 and dll isnt there either)
here is everything, the dll, the project to test the dll, moeurs linker
aWnd is the handle of the window in which the command is being issued, this might not be the currently active window if the command is being called by a remote script.
data is the information that you wish to send to the DLL. On return, the DLL can fill this variable with the command it wants mIRC to perform if any.
parms is filled by the DLL on return with parameters that it wants mIRC to use when performing the command that it returns in the data variable.
Note: The data and parms variables can each hold 900 chars maximum.
show is FALSE if the . prefix was specified to make the command quiet, or TRUE otherwise.
nopause is TRUE if mIRC is in a critical routine and the DLL must not do anything that pauses processing in mIRC, eg. the DLL should not pop up a dialog.
The DLL can return an integer to indicate what it wants mIRC to do:
0 means that mIRC should /halt processing
1 means that mIRC should continue processing
2 means that it has filled the data variable with a command which it wants mIRC to perform, and has filled parms with the parameters to use, if any, when performing the command.
3 means that the DLL has filled the data variable with the result that $dll() as an identifier should return.
Note: You may need to create a .def file with the procedure names exported when compiling your DLL
Last edited by Pouncer; Oct 2nd, 2005 at 02:46 PM.
Re: question for penagate,moeur or codeblock pls regarding dll
As mentioned in the thread about this topic, the dll is still not a true win32 dll. First of all, the dll doesn't initialize properly and second it needs to initialize all the VB runtime stuff. It won't do the later so it must be called from a VB app that has already initialized all the COM stuff.