Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 months ago.
Improve this question
Does anyone know how I can run a VBS code in a C code?
I don't say run an external file, I say run a vbs CODE in the same code as C
In the same way Javascript and HTML come together, I want to do it with C and VBS
Responding to comments
There are two ways to add macro support to your applications. Pay money to Microsoft and license VBA or use VBScript/JScript for free.
C requires a lot of plumbing code. EG a . in C++/VB6 is lines of code in C as it has no knowledge of COM. But to write C one has to choose to use C++ or C# and restrict oneself from using the inbuilt features and then duplicate the same features with lots of lines of code. There is plenty of 20 year old source code on the internet showing how.
VBScript is an Active Scripting language. See https://en.wikipedia.org/wiki/Active_Scripting. This allows COM programming languages to add VBS/JS macros to their programs.
Active Scripting allows you to add a macro language to your program.
You can of course implement IActiveScripting and there is plenty of C code for that on the internet.
For 32 bit programs only there is a MSScript.ocx control that implements IActiveScript and related interfaces in an easy control.
The VBScript code is (I'm not a C programmer - but in C# and C++ [but not C] it is just as easy as VBScript) as they both do COM easily.
set ScriptControl1 = wscript.createObject("MSScriptControl.ScriptControl",SC)
With ScriptControl1
.Language = "VBScript"
.UseSafeSubset = False
.AllowUI = True
.AddCode Script
End With
The documentation was in System32 as msscript.chm but is no longer present in Win 10.
Here is some C# sample code. Note 32 Bit ONLY. https://learn.microsoft.com/en-us/troubleshoot/developer/visualstudio/cpp/libraries/call-script-control-run-method
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have been learning c and data structures for quite some time now and I wanted to see whether I could apply what I have learnt. I searched a bit and found out that I could start with util linux but, before I could do so, I thought I'd check and perhaps dabble a bit with the code for basic unix commands like "cat". I was able to understand what a part of the code might have been trying to do, but I was not able to understand the entire code as a unit.
For example, in the "cat" code, a pointer to the output buffer and input buffer is declared and is appropriately used, which I could understand. What i could not understand, are parts of code like io_blksize (stat_buf) which has no description whatsoever, on what it does. Or how two pointers declared as pointers to the input and output buffers, actually correspond to the input and output buffers ?
So my question being, how do I approach these type of code, how can I understand something that has no description to what it does (in the example given above) and how can I make and implement changes in the code, so that I can see the changes when i run a command ?
(Would really appreciate references or topics I should start with, so that I can relate what I have learnt to how command code's can be modified. I also apologize if the question is to abstract.)
This is a bit of a subjective question so my answers will just be my opinion of course.
A good place to start when you run into something you don't recognise while reading source code is the manpages. Each function will generally have a manpage, e.g. man 2 read or man 3 printf. Beyond that, I feel perhaps you should get more of a foundation in Unix before attempting to read the straight source code, a good book is Advanced Programming in the Unix Environment. I've been working through it myself and am finding my Unix knowledge improving considerably.
Just my two cents.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I was reading "The C Programming Language" by Kernighan & Ritchie and came across some programs which mimic some Unix commands (also implemented in Linux) such as the cat command. The program took command line arguments just like the original cat command.
I am just curious to know whether they are the same thing or not.
Correct me if I'm wrong, any help would be appreciated.
In a command-line environment (such as, of course, Unix/Linux), a principle unit of abstraction is the command. A command has a well-defined interface: the command-line arguments it expects, the input it reads (if any), and the output it generates. You can reimplement a command any time you like, either using a different internal algorithm, or a different language, or just because you want to write your own version. Yes, cat was originally written in C, but we could rewrite it in C++, or Perl, or Python, or sh, or other languages. As long as our reimplementation meets the same interface requirements, we can accurately say that it "is" cat.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What does a file handling mean? What is the difference between them in different languages?, for example perl or c. I'm unable to get a grasp on the concept.
I'm posting an example from perl suggested by #jeegar patel.
open(DATA, " <file.txt");
if you see in this piece of snippet, DATA acts as a file handle, so what exactly is the function/purpose of "DATA" here.
PS: I apologize if this is such a lame question, but I'm trying to get the basics right! Appreciate if anybody could acknowledge this.
In Any programming language, to perform any file operation in programming way it will have some own APIs.
Like C programming has.
http://www.w3schools.in/c/file-handling/
Like perl has
http://www.tutorialspoint.com/perl/perl_files.htm
What is the difference between them in different languages?
You can read file handlings APIs for different programing language and came to know what are different in them..
In fact your program does not get direct access to physical hardware and devices. Your program has to request these as services from the operating system. In each language there is a "run time model" of what a pralooks like, things like where the stack, heap and program memory are. The file system provided by the language is contains the routines needed to coordinate with the operating system, convert data types to the format required by your program and ways to find out the status of the file or even where to put things so the OS will actually write them out
This is complex stuff and each language and language design team has approached the problems somewhat differently.
Trust me they used to be a lot less standardized...
There are many functions on various level of file system hierarchy in the word "File handling".
An example of file system hierarchy and functions in each level:
Handle file systems:
Device/Disk/Directory(Folder)
create/delete/rename/move
Handle a file:
create/delete/rename
Handle a contents of a file:
open/close/read/write
etc.
Each languages have corresponding functions and/or libraries/APIs for "file handling".
When you focused in certain level of hierarchy, "a contents of a file" for example, functions of that level may be comprehensible for you.
Don't to try to see broad functions in all levels at once.
That is not the way of human kind, but of god.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
So what I am looking for is not finding a assembly emulator.
Basically what I am trying to do is translation assembly to c,
Although I have a IDA pro with the "F5" dis-compile function, but
generally I am trying to do a simulation approach.
I made this examples by hand to demonstrate my idea:
mov %eax, 10
add %eax, 5
jmp foo
I want to directly translate it into a simulated c procedure like this
unsigned v_eax = 0;
v_eax = 10;
v_eax += 5;
goto foo;
I think this is pretty like a assembly simulator, which has the process like
assembly --> running in a CPU simulator in C --> output the results
But what I am trying to do is like this
assembly --> translate into a c source code --> compile --> run to get the results
After a quick search, I think this paper has an approach which is similiar to what I am trying to do (however I don't any analysis work, just translation of some simple assembly code)
Could anyone give some help on this issue..?
Thank you!
What help are you looking for? If you have specific questions, ask those questions.
It looks like you've already got the general idea: Set up a bunch of variables to represent the registers, set up a large array to represent the memory, implement either subroutines or macros (chunks of code generated in-line) that represent each instruction and do the Right Thing with those resources, implement additional macros or subroutines which are wrappers for or equivalent to every operating system call or external library function which the programs might invoke (I/O most importantly), write a "loader" for the executable file, then go through the program converting instructions to those macros. Be sure to fix up goto/call addresses properly, and hope like heck that the programmers kept data blocks and code blocks distinct. Get it all debugged, and it should work. Extremely slowly, but that's what you've asked for.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
What are the key differences between Ruby and C?
They are almost totally different.
Ruby
Strong, dynamic typing
Purely object oriented
Automatic garbage collection and no pointers
Interpreted (or JIT compilation with JRuby/IronRuby)
Reflective
Supports functional programming (closures, coroutines, etc.)
No preprocessor or macros
C
Weak, static typing
Procedural (not object oriented)
Not garbage collected and has pointers
Compiled
No reflection
Does not support functional programming
Has a preprocessor and supports macros
To Ruby From C and C++
Why do you ask? Do you have a specific project or goals in mind?
In addition to what others have already mentioned; I'd also say that some key differences to keep in mind is that the C family is much more portable....or rather, much easier to distribute the finished software. C programs will also be much faster than Ruby...whether that is important or not depends on what you are building (well, that's ALWAYS important, but it isn't a make or break proposition for a lot of programs).
Ruby is just simply a beautiful language to work with (do not underestimate the importance of a language that works with you); developing programs is much quicker in Ruby than C ( C is a compiled language, so that is to be expected )...Ruby is also a pretty simple language to learn; most people consider C to be fairly tough for newbies to pick up.
-- edit --
wow, just saw this was a 3 year old thread....my bad