473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Using DynamicInvoke?

I'm using the SciLexer.dll to write a code editor for an in-house scripting
language. I have the editor window up on a form but I need to use it's API.
I've used the following commands to load the dll:

Private scihWnd As Integer 'Scintilla's hWnd
Private SciFunc As Integer 'Scintilla's Main Function Call
Private sciptr As Integer 'Scintilla's Direct Pointer
Private scihmod As Integer 'Scintilla's hMod

scihmod = LoadLibrary("SciLexer.DLL")
If scihmod = 0 Then
Throw New Exception("Unable to load SciLexer.dll")
Exit Sub
End If

scihWnd = CreateWindowEx(...)
SciFunc = GetProcAddress(scihWnd, "Scintilla_DirectFunction")
sciptr = SendMessage(scihWnd, SCI_GETDIRECTPOINTER, 0, 0)

Now I need to call the the SciFunc that was returned from the GetProcAddress
call.

Is this the correct way to do it? I haven't had time to try it yet because
I'm on my way out the door, so I thought i'd ask the question ahead of time.
Here's my tentative code...

Private Function Scintilla(ByVal args() As Object) As Object
Dim t As Type = Nothing
Dim ret As Object = Nothing
ret = Marshal.GetDelegateForFunctionPointer(SciFunc,
t).DynamicInvoke(args)
Return ret
End Function

My next question, isn't there a way to pass an array on the fly without
declaring and filling an array first? Something like:

Scintilla({sciptr,"SCI_SETTEXT",0,"This is my text"})

Thanks!
Jan 7 '08 #1
1 2690
"Terry Olsen" <to******@hotmail.comschrieb:
I'm using the SciLexer.dll to write a code editor for an in-house
scripting language. I have the editor window up on a form but I need to
use it's API. I've used the following commands to load the dll:

Private scihWnd As Integer 'Scintilla's hWnd
Private SciFunc As Integer 'Scintilla's Main Function Call
Private sciptr As Integer 'Scintilla's Direct Pointer
Private scihmod As Integer 'Scintilla's hMod

scihmod = LoadLibrary("SciLexer.DLL")
If scihmod = 0 Then
Throw New Exception("Unable to load SciLexer.dll")
Exit Sub
End If

scihWnd = CreateWindowEx(...)
SciFunc = GetProcAddress(scihWnd, "Scintilla_DirectFunction")
sciptr = SendMessage(scihWnd, SCI_GETDIRECTPOINTER, 0, 0)
A Window handle does not have functions. The first parameter of
'GetProcAddress' expects a 'HMODULE'. You can use the handle returned by
'LoadLibrary' there.
My next question, isn't there a way to pass an array on the fly without
declaring and filling an array first? Something like:

Scintilla({sciptr,"SCI_SETTEXT",0,"This is my text"})
'Scintilla(New Object() {..., ...})'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 7 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using...
3
by: Todd Schinell | last post by:
Back in July, Jeffery Tan posted this: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OWOTdf0VDHA.2296%40cpmsftngxa06.phx.gbl In response as to how to get click events from a...
3
by: Oscar Thornell | last post by:
Hi, I am thinking about doing all my logging asynchronously using a delegate. The main resaon for this would be performance and responsiveness of the application (an ASP.NET app). //Exampel...
1
by: keith.walter | last post by:
My first asp.net app is almost "done" and I am stuck. Here is my situation: I have a "mother" page add_customer.aspx and a"child" user control add_group.ascx. On the mother page is an "add...
3
by: Amir Shitrit | last post by:
Hi to all. Whats the difference between DynamicInvoke and Invoke methods of the Delegate class? Thanks in advance.
2
by: mswlogo | last post by:
I looked high and low for code to do this and finally found some VB code that did it right. This is a C# flavor of it. public event EventHandler<EventArgsMyEventToBeFired; public void...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
1
by: =?Utf-8?B?aGVyYmVydA==?= | last post by:
Jon Skeet wrote in the .NET general newsgroup 11/17/2005: "The difference between Invoke and DynamicInvoke is that the parameters to Invoke depend on the delegate itself - the method has the same...
5
by: puzzlecracker | last post by:
I've just discovered DynamicInvoke methods while reading Jon's threading article. And my question is how it's different from a regular invoke method? In this method: /// <summary> ///...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.