Search found 13 matches

by franchsesko
Fri Jul 12, 2019 11:53 am
Forum: Tricks 'n' Tips
Topic: Registry-free COM loader (Redemption.dll full sample)
Replies: 5
Views: 3749

Re: Registry-free COM loader (Redemption.dll full sample)

Hi Guys, back here after a while, thanks for your replies, awesome work and code on the COM/ActiveX topic in these forums ( :wink: @mk-soft).
Happy that you found your way with Enigma @mohsen.
The technique I followed here for "registry free" COM/ActiveX object libraries (dlls).
This means you don't ...
by franchsesko
Sun Nov 11, 2018 8:59 am
Forum: Tricks 'n' Tips
Topic: Registry-free COM loader (Redemption.dll full sample)
Replies: 5
Views: 3749

Re: Registry-free COM loader (Redemption.dll full sample)

I should have mentioned that this work in classic VB (VB5/6) but alas not VBA (Office).

For Redemption, here's also the source for a second DLL that wraps ProfMan.dll (compile that one to ProfManLoader.DLL, the previous one to RedemptionLoader.dll, to match the VB declares):


EnableExplicit ...
by franchsesko
Sun Nov 11, 2018 8:28 am
Forum: Tricks 'n' Tips
Topic: Registry-free COM loader (Redemption.dll full sample)
Replies: 5
Views: 3749

Registry-free COM loader (Redemption.dll full sample)

Hi,

If you use 3rd party ActiveX (ie COM) DLLs, or your own, and you want to distribute them without having to register them on the target system (no regsvr32), you can use this technique.
The idea is to write an intermediate DLL that'll create the ActiveX objects for you and return you a reference ...
by franchsesko
Tue Jun 12, 2018 2:59 pm
Forum: Coding Questions
Topic: Returning Strings to VBA - Is this the right way ?
Replies: 15
Views: 3380

Re: Returning Strings to VBA - Is this the right way ?

If this variable is not created, it leads to a crash.
I agree.

A function can also be called as a sub. The return value is then ignored by the DLL.
Agreed too (although it's VB/A ignoring the return code).

The cleaning up of the variable 'text' is done automatically by VB.
That is what I was ...
by franchsesko
Tue Jun 12, 2018 1:39 pm
Forum: Coding Questions
Topic: Returning Strings to VBA - Is this the right way ?
Replies: 15
Views: 3380

Re: Returning Strings to VBA - Is this the right way ?

@mksoft,

I'll take the Array example as another cool Bonus, thanks :wink:

I think you got a problem with the ByRef variant because of extra parenthesis.
You have:

Private Declare PtrSafe Function GetVersion Lib "ReturnStringTest.dll" () As String
Private Declare PtrSafe Function ...
by franchsesko
Mon Jun 11, 2018 11:04 pm
Forum: Coding Questions
Topic: Returning Strings to VBA - Is this the right way ?
Replies: 15
Views: 3380

Re: Returning Strings to VBA - Is this the right way ?

Hi mk-soft,

Woaw, that is great.
I love the second one that can alter a variant passed by reference (no need to maintain pointers in the library, no need for conversion).
Also wouldn't have thought using "Thread(ed)" variables until now too.

Anyway, here's the updated and tested code (need to use ...
by franchsesko
Mon Jun 11, 2018 2:08 pm
Forum: Tricks 'n' Tips
Topic: Dynamic array of long integers module
Replies: 3
Views: 1503

Re: Dynamic array of long integers module

Hi NickTheQuick,

Very good point indeed, and thanks for the link.

I'm working with relatively small arrays (handles/entries indices in another dynamic array), so I've bet on a relatively safe initial size and then an expansion that should remain exceptional and moderate.

I think I'm convinced by ...
by franchsesko
Mon Jun 11, 2018 10:53 am
Forum: Coding Questions
Topic: Returning Strings to VBA - Is this the right way ?
Replies: 15
Views: 3380

Re: Returning Strings to VBA - Is this the right way ?

Just to follow up on my last resort technique, here's a version where I return a string with a more traditional buffer/copy technique (GetVersionLength/GetVersionV2).
Although there's a Unicode/Ascii(PB)/Unicode(VB/A) conversion in the process, so some potential loss.

PB DLL:

EnableExplicit ...
by franchsesko
Mon Jun 11, 2018 10:20 am
Forum: Coding Questions
Topic: Returning Strings to VBA - Is this the right way ?
Replies: 15
Views: 3380

Re: Returning Strings to VBA - Is this the right way ?

Hi bernd,

Thanks for chiming in.

And OLECHAR is wchar_t which is an UTF16 string.
So it is 'normal' that there are 0 bytes after each 'ASCII' character.

I agree with that.

One other thing ... you need to free the memory occupied by SysAllocString_()
That is what I fear.

When I return the ...
by franchsesko
Mon Jun 11, 2018 10:02 am
Forum: Coding Questions
Topic: Returning Strings to VBA - Is this the right way ?
Replies: 15
Views: 3380

Re: Returning Strings to VBA - Is this the right way ?

Thanks for the collection and the links Kwai.
I think I've got quite some lessons from the Masters here to go, before even considering myself to be an apprentice ;-)

So, basically, I'm doing it the "GetDirectString3()" way, except that I don't do the PokeS() thing as PB is now Unicode (UTF16 ...
by franchsesko
Mon Jun 11, 2018 8:39 am
Forum: Tricks 'n' Tips
Topic: Dynamic array of long integers module
Replies: 3
Views: 1503

Dynamic array of long integers module

Hi,

I recently wrote this module to be able to have dynamic arrays of long integers (PB Long type) in structures.
Its a kind of stack to which you give an initial size (DALCreate()) and that automatically grows when pushing Longs (DALPushLong()).
Longs can be set/retrieved (DALSetLong()/DALGetLong ...
by franchsesko
Mon Jun 11, 2018 8:12 am
Forum: Coding Questions
Topic: Returning Strings to VBA - Is this the right way ?
Replies: 15
Views: 3380

Re: Returning Strings to VBA - Is this the right way ?

Hi kwai,

Thanks for jumping into this topic.
Actually yes, I've seen COMate, great work indeed, but I left it aside as I'm writing a non COM Dll (although I rudely borrow SysAllocString() from it).
I'll dig into it, but if you can point me where you know there's some code that can help me, it may ...
by franchsesko
Mon Jun 11, 2018 7:47 am
Forum: Coding Questions
Topic: Returning Strings to VBA - Is this the right way ?
Replies: 15
Views: 3380

Returning Strings to VBA - Is this the right way ?

Hi,

Using the SysAllocString() api, we can return a pointer to a BSTR that VBA (32 and 64 bits) almost understands as one of its strings.

PB DLL sample:
EnableExplicit
DisableDebugger

#APP_VERSION = "1.0.0"

ProcedureDLL.i GetVersion()
ProcedureReturn SysAllocString_("This is Version " + #APP ...