|
Why do you need it?
Could you use Cygwin [^] environment?
[added]
Damned monkeys!!!
[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I didn't use cygwin alredy and I want to find a solution except this. if there isn't other way please tell me how can i use it?
thanks a lot.
|
|
|
|
|
How do I get the hToken needed for CreateProcessAsUser? I have a DLL that is loaded runs from the context of user1 and then from user2. From user2, I want to create a process as user1.
From MSDN:
BOOL WINAPI CreateProcessAsUser(
__in_opt HANDLE hToken,
__in_opt LPCTSTR lpApplicationName,
__inout_opt LPTSTR lpCommandLine,
__in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes,
__in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
__in BOOL bInheritHandles,
__in DWORD dwCreationFlags,
__in_opt LPVOID lpEnvironment,
__in_opt LPCTSTR lpCurrentDirectory,
__in LPSTARTUPINFO lpStartupInfo,
__out LPPROCESS_INFORMATION lpProcessInformation
);
What I want to do is something like this:
1. user1 process loads my DLL
2. my DLL gets the current process hToken (???this is the part i don't get???)
3. my DLL stores that in a txt file.
4. user1 process closes
5. user2 process starts and loads my DLL
6. my DLL reads all the needed data from txt file
7. my DLL starts a process as user1.
user2 process is always guaranteed to run only *after* user1 process. They don't run simultaneously.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
LogonUser() function can be used to get the token.
|
|
|
|
|
I don't have the password for the user, which LogonUser requires.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
In that case you can enumerate all processes to find out the PID for explorer.exe
Use OpenProcess() API to get process handle for explorer.
Use OpenProcessToken() API to get the token handle for explorer.exe.
Use the this token handle in the CreateProcessAsUser() API.
It would work because explorer.exe runs in the logged-in user's account.
|
|
|
|
|
That might work, but it's inherently an unstable solution, mostly because user1 might be or not be the same user as explorer.exe. It's not guaranteed to be the logged on user. It's just whichever process loaded my DLL first.
Wouldn't it be better to use GetCurrentProcess() instead, while my DLL is loaded in user1 process, and then use OpenProcessToken?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Yes, it seems GetCurrentProcess() would be a good try.
|
|
|
|
|
Hi,
I have an MFC unicode application which needs to access a database which is UTF-8 encoded. Iam accessing the database through direct query excution using ExecuteSQL function.ExecuteSQL functions expects an LPCTSTR which will be be LPCWSTR under _UNICODE , so i need to format the query as UTF-16 and pass to the ExecuteSQL right?, but the DB is UTF-8 encoded.I need to know whether this will cause any problems.?
Thanks
Krish
|
|
|
|
|
i am doing an word automation application in vc++. Here i need to create tables, which i have done. Now i need to set the borders for the tables. the tables that are created does not have borders by default.
i did some R&D and created gridlines. But that is not what i wanted. I wanted borders for the tables. Please give me some leads on this
|
|
|
|
|
Please see this automation code (VB) this will give a hint
.Borders(wdBorderTop)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
Shows that you should select the Borders collection of particular table and then set the LineStyle and LineWidth values/properties.
Also be sure that Borders.Enabled is true .
|
|
|
|
|
Hi All,
I am using CFtpConnection to upload the files on to the ftp server. It works fine for upload the files on to the server. My problem is that how i find the progress of the file i.e. how much file uploaded on to the server. please help me.
|
|
|
|
|
raj1576 wrote: My problem is that how i find the progress of the file
You could use CInternetFile's Open and Read method to write the file yourself, giving you the ability to easily calculate the progress.
Also try using CInternetSession::OnStatusCallback[^] for status updates.
|
|
|
|
|
Thanks for reply
I tried Also Open and Read method but this is synchronous but I want asynchronous. so I use CFtpConnection. I also tried OnStatusCallback but I am not getting how I use this callback function.Pls help somithing for using this callback function.
|
|
|
|
|
|
|
Hi all,
i have made a dll i want to use that dll in my program i have called the function of that dll using this code
typedef void (*function1_ptr) ();
function1_ptr function1=NULL;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HMODULE myDll = LoadLibrary("myfile.dll");
if(myDll)
{
function1 = (function1_ptr) GetProcAddress(myDll,"function1");
if(function1)
function1();
FreeLibrary(myDll);
}
return 0;
}
i have copied my dll in debug folder, but control is not going inside if statement...
how should i do it....
can anybody please help me...
Thanks in advance
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Try giving full path in LoadLibrary.
HMODULE myDll = LoadLibrary("myfile.dll");
to something like
HMODULE myDll = LoadLibrary("C:\\Myproject\\debug\\myfile.dll");
|
|
|
|
|
What the error return code you are getting from LoadLibrary function?
|
|
|
|
|
GetProcAddress(myDll,"function1");
maybe the 2nd parameter is the key.
you could use "dumpbin /exports myfile.dll" to check the exported functions' name.
then,give the right name string.
i think your dll should include .def file
modified on Tuesday, December 29, 2009 3:16 AM
|
|
|
|
|
Le@rner wrote: but control is not going inside if statement...
Which one ? The one after the call to LoadLibrary or the one after the call to GetProcAddress ? If this is the second call, make sure that you have provided a module defintion file (.def file) as explained in the documentation[^]
|
|
|
|
|
hi:
How to generate random file names? It is better provide a simple method. thanks 
|
|
|
|
|
Have you tried GetTempFileName() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
UINT GetTempFileName(
LPCTSTR lpPathName, // pointer to directory name for temporary
// file
LPCTSTR lpPrefixString, // pointer to filename prefix
UINT uUnique, // number used to create temporary filename
LPTSTR lpTempFileName
// pointer to buffer that receives the new
// filename
);
I am not a genius, but shed more sweat!
|
|
|
|