Hi!
I need to use source code written in C with my application whch is written in Visual Basic 6.
I have no choice, I don't know C and must to use existing.
Is possible to combine C and VB6 code in single application?
Thank you for each help.
Miro
Printable View
Hi!
I need to use source code written in C with my application whch is written in Visual Basic 6.
I have no choice, I don't know C and must to use existing.
Is possible to combine C and VB6 code in single application?
Thank you for each help.
Miro
Yes and no
No you can't combine the code
Yes you can create a dll and use it in your VB project.
Wouldn't that be great! If the C code was written as, and compiled into, a DLL, then it is possible. But raw source code from another language needs to be converted to VB
Ah, DM beat me to it
Ok, how to create DLL for C sources?
Is Visual C++ backward compatible with C?
How to create DLL? Even, how to call DLL?
Application in C has no one parameter - after start searches for file in same directory as app and process it...
Can you help?
Miro
If the C code behaves in that way then converting it to a DLL could be a lot of work, especially if this isn't something you have done before. Depending on the complexity of the C code it might be possible to rewrite it in VB.
It is very simple code - in less than 100 lines. Sources are 5 and else 3.
These codes I tried to convert by converter - it failed in some parts - so I'm not able to do it...
It is simple tool to render images for Commodore 128 VDC chip - 5 and 3 sources are for 8 modes totally.
Miro
Sounds like you could just compile the C code into an exe and shell to it from your vb program
Yes, it is alternative, but problem is that it outputs to console during rendering - outputs curent processing column number.
Miro
Where do you want to output it?
You could just run the code in a cmd window and redirect the output to a file then read the file into a VB program if needed.
C:\Users\passel>Ccode.exe > VDCchipImage.dat
C:\Users\passel>
For test I tried to use it by shortcut:
cmd /c render.exe > output.txt
and set window minimized.
Process was indicating in taskbar and output to file was empty, when I restore window I see progress...
Only one problem is here - how to hide application indication in tasksbar?
Not yet applied in VB.
Miro
You may want to try the abandoned ThunderVB project. Download it either from PSC or SourceForge.
If you just post your source here, there are a bunch of us fluent in C and many other languages.
I just posted some source in the C/C++ thread on how to deal with a ParamArray from C, but it sounds like it would be sooo much easier just converting it by hand.
and yes VC can compile C.
http://www.vbforums.com/showthread.p...n-C-export-DLL
I know that C source code is published under GNU GPL, but I know author personally and must to ask if can I publish it here.
Miro
Vic
Somewhat off-topic, but how did you do that?
I've modified your string by adding "x" so it just appears here as text ..
[xCENTER][xATTACH=xCONFIG]150621[x/ATTACH][x/CENTER]
Could you explain
Is it a video?
Spoo
I used Visual C++ same generation as VB6, compile some DLL in it, and called it from VB, it is just the _stdcall , the only one thing is to export the functions the dll must provide to VB.
Then place it next to the APP EXE, and just use it.
The easier is using all parameters in 32bits, so the signature must be long long long...., include if in the VB you uses it as boolean, or integer, it is in real LONGs, include strings, strings it is just a LONG pointer to the string header, then from the header you must read the pointer to the string itself, ooooor strptr to pass directly the pointer to the string. Then it is the things C++ likes null terminated strings, or you do special C code to read the LENGTH at [StrPtrr-4] IIRC
Include the DLL will always works as a function, include if it is VOID, it is structured as a function, the Return value is passed in EAX.
that is the _stdcall. All is passed by stack, and locals are allocated in stack, x86 is perfectly designed to do that, but you don't see that fact in C++, the language abstracts that well. You will see those facts if coding in ASM, which also I did. As an old asm guy.
Ok, I do all possible to contact creator of code 'cause friend usedit from other man.
I'll reply when I will know if is possible to publish it.
Miro
Ok, I have agreement to publish sources in C.
Have I create code parts in text or attach them to post?
Miro
Hmmm, through the years, I've been involved with a couple of different applications that were written in C. However, these were stand-alone applications, and we didn't compile anything to a DLL. I must admit that I've had very little to do with C++.
Another thing I was a bit more recently involved with was dealing with a few Fortran algorithms. Using the Microsoft Fortran Compiler, I was able to create a standard callable DLL that's called from VB6. And I don't remember this being a great deal of work.
With admittedly somewhat limited knowledge, it's a bit confusing to me why one couldn't just find a C compiler that would create a standard DLL that could be called from VB6. I'm guessing that an ActiveX DLL might be more work. However, if all we're after is certain algorithms, it seems that a standard DLL could get it done.
Best Regards,
Elroy
So, I attached files in ZIP.
I hope that anybody has bit of time to help me by converting it to Visual Basic.
I tried converter but some parts marked as error and in VB source was original code line.
About files:
****************
VDC file lines
---------------------
hfli_quant.c 231
i3vdc_quant.c 217
image.c 211
image.h 38
ivdc_quant.c 226
matrix.h 24
vdc_quant.c 228
================
VGA file lines
---------------------
hfli_quant.c 231
image.c 211
image.h 38
matrix.h 24
tfli_quant.c 231
****************
some files looking same, but I'm not able to be sure 'cause don't know C.
Thank you all for at least reading it.
Miro
Attachment 150751