|
Thanks, but I have all the source code right in front of me and I wrote it myself.
|
|
|
|
|
The question was how to change in inside the .exe file. If you have the source file, how is there a question?
|
|
|
|
|
The .exe file itself should change the array inside another .exe-file (which happens to be a copy of the original .exe-file) during runtime.
|
|
|
|
|
You can load the array from any number of (safe) sources. Why "inside" an executable?
You can change the sourcecode from the executable and compile it again from the running program. Seems very excessive though.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
It seems like that would be unsafe and would create unnecessary vulnerabilities to Hacking and Malware.
|
|
|
|
|
You can't; well you can but the complications arising from such an activity would take years to get right. And as soon as the exe file is rebuilt all your addresses will be wrong. It seems to me you are trying to solve a problem that does not exist. You need to put all your text data in some file format that only your application can understand which is far less difficult than trying to hack the executable.
|
|
|
|
|
If the number of elements can change, don't use an array, use a List<byte>.
|
|
|
|
|
Can only conclude from your evasiveness you're trying to modify someone else's exe and you don't have the source code. Otherwise, you would make a large enough array to hold any "future" "patched" entries.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi all!
I've got a Windows Forms (C#) project with a combobox that is populated when the form loads
The problem is that the loading of the combobox is slow, and since the loading is done when the form is trying to display the entire form isn't shown until the combobox have been populated. This can in some circumstances be 20+ seconds.
I've tried the code below, using async and await , but it not works....return error :
"This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread."
Any help will be appreciated....
Thank you...
private async void Form1_Load(object sender, EventArgs e)
{
await Task.Run(() =>
{
LoadMyCombo();
});
}
private async void LoadMyCombo()
{
OleDbConnection con = new OleDbConnection(conex);
string strSQL = "select * from Customers order by cust_name";
try
{
con.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(new OleDbCommand(strSQL, con));
DataSet ds = new DataSet();
adapter.Fill(ds);
mycombo.DataSource = ds.Tables[0];
mycombo.ValueMember = "code";
mycombo.DisplayMember = "cust_name";
}
catch (System.Exception erro)
{
MessageBox.Show("Error.... " + erro.Message);
}
|
|
|
|
|
Your design probably needs to be looked at if the combo takes 20 seconds to load, you are trying to load way too many records, try preceding the combo with a filter turning it into a search.
If there are more than 100 records in the combo then it is unusable.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Thanks for reply Holmes, but there are aprox. 34,000 records to load from the table 'Customers'.....and I can´t filter only 100 or 200 records, because the user needs to choose a customer from the list....
How can I deal with this...?
Thanks in advance...
|
|
|
|
|
Carlos58 wrote: 34,000 records to load from the table 'Customers' And there is your problem! That is sheer lunacy, think about the workflow from a users POV. He/she approaches you form, they MUST know something about the customer before they start, they are not going to pick a random customer from 34k.
You MUST allow them to enter some text (usually 3 characters) to filter the selection if the name is the criteria, THEN you populate the combo.
If the name is not known the they must have some other information to filter the list by - geographic, product, size, credit rating, there must be some knowledge about the customer they can use to filter the list.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Ok Holmes... sorry, but I didn't know about this C# limitation ....I will accept your suggest, allowing them to enter some text.
Thank you !
|
|
|
|
|
This isn't a limitation of C#, but of how Windows and controls work.
The combobox control you drag over from the toolbox is just a wrapper for a standard Windows control from the Common Controls Library. The way these controls works requires sending messages to the controls to get them to do things, like add an item to a collection in your combobox.
|
|
|
|
|
That is not a technological limitation, it is common sense.
If you were to create the Google search engine, would you have a zillion answers (the entire database) on a single web page without a textbox where one can enter a question?
|
|
|
|
|
If you're only going to put the "name" and "code" in the combo box, WHY ARE YOU DOWNLOADING THE ENTIRE CUSTOMER TABLE?! Inquiring minds would like to know.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Avoid async void methods | You’ve Been Haacked[^]
Try something like this:
private void Form1_Load(object sender, EventArgs e)
{
_ = OnFormLoadAsync();
}
private async Task OnFormLoadAsync()
{
try
{
DataSet ds = await Task.Run(() => LoadCustomers());
mycombo.DataSource = ds.Tables[0];
mycombo.ValueMember = "code";
mycombo.DisplayMember = "cust_name";
}
catch (Exception error)
{
MessageBox.Show("Error.... " + erro.Message);
}
}
private DataSet LoadCustomers()
{
const string query = "SELECT * FROM Customers ORDER BY cust_name";
using (OleDbConnection con = new OleDbConnection(conex))
using (OleDbCommand cmd = new OleDbCommane(query, con))
{
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
}
} But as others have said, loading thousands of records into a combobox is not a good idea.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Using C# code only, how can I get the list of outgoing MSMQ queues ?
|
|
|
|
|
Have a look at the MessageQueue.GetXXX methods!
|
|
|
|
|
Not working... as I mention previously, the MessageQueue.GET... methods show the Public and/or Private queues but not the OutGoing Queues...
I can "create" outgoing queue by send message with exact syntax of connection but can't get the list of current outgoing queues...
|
|
|
|
|
|
Hi,
Thanks, already look at this article, the problem is how to find "...Object library" (either version 1.0, 2.0 or 3.0) that support by new OS versions (Win 10).
Anyway, thanks for the tips
|
|
|
|
|
Hello,
I have a dll created with delphi language (Borland Delphi 7) which thus contains functions in delphi which I would like to use in C# under Visual Studio 2017. It is a native dll.
I want to use for example the GENERATE_FILE function contained in test.dll.
Delphi code :
procedure GENERATE _FILE(Path, Input_File : AnsiString); stdcall;
procedure GENERATE _FILE(Path, Input_File : AnsiString); stdcall;
var
begin
…
GENERATE_CALC(Path_And_File, CRC32, Total, err);
…
end;
In C#, I want to use the function GENERATE_FILE contained in test.dll but what is the type of the parameters Path and Input_File in C# ?
Below is an example of C# code I made to use test.dll in delphi in C#. I set string as a type for parameters of the function GENERATE_FILE.
namespace AppTest
{
Public class Program
{
[DllImport("test.dll", CharSet = CharSet.Ansi)]
public static extern bool CREATE_FILE(string pathDirectory, string filename);
static void Main(string[] args)
{
GENERATE_FILE(@"C:\Users", "file.txt");
}
}
}
I added the test.dll in Visual Studio by right clicking on the project then add an existing element, then, in the properties of the test.dll, I put "Content" in Generation action and I put "Always copy "(output directory). When I run the solution, I have the test.dll in bin\Debug.
But when I test this program, I get the following error at the line that contains:
GENERATE_FILE(@"C:\Users", "file.txt");
System.DllNotFoundException: 'Unable to load DLL' test.dll ': The specified module could not be found. (Exception from HRESULT: 0x8007007E) '
How to solve this problem ?
I think the issue is about the type of parameters in the function GENERATE_FILE. What are the type equivalents between delphi and C# for the function GENERATE_FILE ?
Thank you for your help.
|
|
|
|
|
In C#, you can only use the string type.
See Calling a Delphi DLL from a C# .NET application - Stack Overflow[^] and be sure to read the entire thing. There are links you're going to have to follow and read.
Depending on what your Delphi code is doing, you may need to rewrite it to support being called from an external caller.
|
|
|
|
|
Quote: I think the issue is about the type of parameters
Why? the error message was pretty clear, it said Quote: 'Unable to load DLL test.dll
which may not be entirely accurate, it would better be "unable to load DLL test.dll or some of its dependencies" (that is other DLL's your test.dll might be relying on).
Don't worry about your parameter types right now, first make sure you have all the required DLL files are in a location where the .NET executable can find them. Maybe start looking here[^].
BTW: your DLL files will need to have the same 32-bit/64-bit choice your .NET code has.
FYI: AFAIK there also is Delphi.NET which would mean you could recompile your Delphi code (assumed available) and use its output as a regular .NET DLL, without any P/Invoke stuff.
|
|
|
|